refactor(config): distinguish model names from objects#326
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThe PR renames guidance and job model identifiers from ChangesModel identifier rename
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR implements the rename of configuration/result fields from model → model_name to reduce ambiguity between a model name (string/enum) and a loaded model object, while preserving the public CLI flag --model. It also introduces backward-compatible migration for legacy pickled objects and legacy results.json entries to avoid breaking queued jobs or duplicating historical grid-search runs. (Confidence: ~85%)
Changes:
- Renamed
GuidanceConfig,JobConfig,JobResult, and grid-search config/result fields frommodeltomodel_namewhile keeping--modelwired todest="model_name". - Added pickle migration via
__setstate__()forGuidanceConfigandJobResultto transparently load legacymodelstate intomodel_name. - Normalized legacy grid-search
results.jsonrun records (model→model_name) during merge to prevent duplicate entries.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/utils/test_guidance_script_utils.py | Updates test fixtures/expectations to use model_name and assert legacy model key is absent in metadata. |
| tests/utils/test_guidance_script_arguments.py | Updates argument/config tests to model_name and adds pickle migration tests for GuidanceConfig and JobResult. |
| tests/utils/conftest.py | Renames JobResult fixture field to model_name. |
| tests/test_run_grid_search.py | Adds coverage ensuring legacy results.json records using model are normalized to model_name without duplication. |
| tests/integration/test_mismatch_integration.py | Updates integration test config creation to use model_name. |
| tests/cli/test_guidance_cli.py | Updates CLI parsing tests to assert config.model_name while keeping --model unchanged. |
| src/sampleworks/utils/guidance_script_utils.py | Switches runtime result creation and job-queue model resolution to model_name. |
| src/sampleworks/utils/guidance_script_arguments.py | Renames config/result fields, updates --model parsing to dest="model_name", and adds __setstate__() migrations. |
| src/sampleworks/cli/guidance.py | Updates CLI entrypoint to pass config.model_name into model construction. |
| run_grid_search.py | Renames grid-search config/job/result handling to model_name and normalizes legacy results.json runs when merging. |
| GRID_SEARCH.md | Updates documentation log example to show model_name=.... |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def from_cli( | ||
| cls, | ||
| argv: list[str] | None = None, | ||
| model: str | None = None, | ||
| model_name: str | None = None, | ||
| guidance_type: str | None = None, | ||
| ) -> GuidanceConfig: | ||
| """Parse CLI arguments and return a fully populated GuidanceConfig. | ||
|
|
||
| When *model* and *guidance_type* are provided (e.g. from legacy | ||
| When *model_name* and *guidance_type* are provided (e.g. from legacy | ||
| scripts), they are used directly and ``--model`` / ``--guidance-type`` | ||
| are not required on the command line. Otherwise they are parsed as | ||
| required CLI arguments. | ||
| """ | ||
| model_choices = [m.value for m in StructurePredictor] | ||
| guidance_choices = [g.value for g in GuidanceType] | ||
| model_preset = model is not None | ||
| model_preset = model_name is not None | ||
| guidance_preset = guidance_type is not None |
marcuscollins
left a comment
There was a problem hiding this comment.
Is this basically identical to the code you had for the Protpardelle branch?
I just have the same comment as there that I'm not sure backwards compatibility is required, but I don't think it is a huge deal one way or the other. I'll approve and you can do as you see fit.
Closes #289.
Renames guidance, grid-search, and result fields from
modeltomodel_namewhile retaining the public--modeloption.Existing pickled
GuidanceConfig/JobResultobjects and legacyresults.jsonrecords are migrated on load, preventing broken queued jobs or duplicate historical run entries.Validation:
uv run --python 3.12 --group dev pytest tests/cli/test_guidance_cli.py tests/utils/test_guidance_script_arguments.py tests/utils/test_guidance_script_utils.py tests/test_run_grid_search.py(114 passed)uv run ruff check ...uv run ty check ...Summary by CodeRabbit
modeltomodel_nameacross command-line options, job settings, and result metadata.modelfield, automatically migrating them tomodel_name.