fix: map MIPROv2 trial history to AcceptedIteration schema to prevent…#2425
Open
Redtius wants to merge 2 commits intoconfident-ai:mainfrom
Open
fix: map MIPROv2 trial history to AcceptedIteration schema to prevent…#2425Redtius wants to merge 2 commits intoconfident-ai:mainfrom
Redtius wants to merge 2 commits intoconfident-ai:mainfrom
Conversation
… validation errors
|
Someone is attempting to deploy a commit to the Confident AI Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
PR author is not in the allowed authors list. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Hello again! While working with MIPROv2, I encountered a second issue that occurs at the very end of the optimization process. Even after the trials complete successfully, the library crashes when generating the final report.
The Issue:
MIPROv2 stores its internal trial history as raw dictionaries. However, the OptimizationReport Pydantic model requires the accepted_iterations field to be a list of AcceptedIteration objects. This leads to a ValidationError (especially on Pydantic v2), preventing the user from seeing the final results:
❌ BUG 2 REPRODUCED: [MIPROv2] • error ValidationError: 10 validation errors for OptimizationReport accepted_iterations.0.parent Field required [type=missing, input_value={'trial': 1, 'instr_idx':...o_idx': 0, 'score': 1.0}, input_type=dict] For further information visit https://errors.pydantic.dev/2.11/v/missing accepted_iterations.0.child Field required [type=missing, input_value={'trial': 1, 'instr_idx':...o_idx': 0, 'score': 1.0}, input_type=dict] For further information visit https://errors.pydantic.dev/2.11/v/missing accepted_iterations.0.module Field required [type=missing, input_value={'trial': 1, 'instr_idx':...o_idx': 0, 'score': 1.0}, input_type=dict] For further information visit https://errors.pydantic.dev/2.11/v/missing ##############...#################accepted_iterations.1.before Field required [type=missing, input_value={'trial': 2, 'instr_idx':...o_idx': 0, 'score': 1.0}, input_type=dict] For further information visit https://errors.pydantic.dev/2.11/v/missing accepted_iterations.1.after Field required [type=missing, input_value={'trial': 2, 'instr_idx':...o_idx': 0, 'score': 1.0}, input_type=dict] For further information visit https://errors.pydantic.dev/2.11/v/missing • halted before first iterationThe Fix:
I have updated the _build_result method to map the trial history into the AcceptedIteration schema. This ensures the data is correctly validated while preserving the trial scores for the report.
Reproductible Case
I prepared a mock case that reproduces the issue without requiring any external API keys or complex setups: