Skip to content

Fix #129: Auto-generate config dumps from Pydantic models#136

Open
Devguru-codes wants to merge 2 commits intoOSIPI:mainfrom
Devguru-codes:fix/129-autogen-config-dump
Open

Fix #129: Auto-generate config dumps from Pydantic models#136
Devguru-codes wants to merge 2 commits intoOSIPI:mainfrom
Devguru-codes:fix/129-autogen-config-dump

Conversation

@Devguru-codes
Copy link
Copy Markdown
Contributor

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 -

  1. 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.

  2. 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)).

  3. 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).

  4. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor config dumps to use Pydantic model introspection

1 participant