Skip to content

Refactor config dumps to use Pydantic model introspection #129

@ltorres6

Description

@ltorres6

Problem

dump_defaults() in osipy/cli/config.py returns hard-coded YAML template strings from the _DEFAULT_TEMPLATES dictionary (lines 398–532). These templates are manually maintained and have already drifted from the actual Pydantic config classes — for example, delay fitting options (fit_delay, delay_bounds) exist in the fitting API but are absent from the templates.

As we add more parameters across modalities, keeping hand-written templates in sync with the Pydantic models is unsustainable.

Proposal

Replace the hard-coded _DEFAULT_TEMPLATES strings with auto-generated YAML derived from the Pydantic model schemas. For example:

  • Use model_json_schema() or model_fields to iterate over each config class
  • Emit field names, defaults, types, and descriptions as commented YAML
  • Ensure the output stays human-readable (grouped by section, with comments from Field(description=...))

This guarantees that every field defined in the Pydantic config classes automatically appears in the config dump, eliminating drift.

Affected code

  • osipy/cli/config.py_DEFAULT_TEMPLATES dict and dump_defaults() function
  • All Pydantic config classes: DCEFittingConfig, DCEPipelineYAML, DSCPipelineYAML, ASLPipelineYAML, IVIMPipelineYAML, etc.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions