Fix #129: Auto-generate config dumps from Pydantic models#136
Open
Devguru-codes wants to merge 2 commits intoOSIPI:mainfrom
Open
Fix #129: Auto-generate config dumps from Pydantic models#136Devguru-codes wants to merge 2 commits intoOSIPI:mainfrom
Devguru-codes wants to merge 2 commits intoOSIPI:mainfrom
Conversation
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.
Hello @ltorres6 sir, I saw the issue and I have worked on it. This PR refactors the CLI configuration dumping mechanism to automatically generate YAML templates directly from the Pydantic model schemas, permanently eliminating drift between hard-coded strings and the actual schemas.
The changes that i have made are -
Automated Generator:- Replaced the hard-coded _DEFAULT_TEMPLATES dictionary in config.py with an introspection function (_generate_section_yaml) that dynamically builds the YAML hierarchy based on model_fields.
Documentation Injection:- Added Field(default=..., description=...) parameters to over 50 model attributes. These descriptions are automatically parsed and appended as inline comments to guide the user (e.g., te: 30.0 # echo time (ms)).
Structure Maintained:- The outputs remain grouped logically. Active fields map to their defaults, while Optional settings defaulting to None are neatly emitted as commented-out lines (e.g., # flip_angles: null).
Anti-Drift Guardrails:- Added a new parameterised test (test_dump_defaults_covers_all_model_fields) to guarantee that any field added to a Pydantic model in the future mechanically shows up in the auto-generated templates.
The new tests will help catch configuration mismatches and prevent any similar issues going forward.
I will wait for your response. If you think this pr needs any updates, please tell me and I will implement it. Thank you.
Fixes #129