Skip to content

refactor(config): distinguish model names from objects#326

Open
xraymemory wants to merge 1 commit into
mainfrom
xraymemory/issue-289-model-name-main
Open

refactor(config): distinguish model names from objects#326
xraymemory wants to merge 1 commit into
mainfrom
xraymemory/issue-289-model-name-main

Conversation

@xraymemory

@xraymemory xraymemory commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Closes #289.

Renames guidance, grid-search, and result fields from model to model_name while retaining the public --model option.

Existing pickled GuidanceConfig/JobResult objects and legacy results.json records 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

  • Updates
    • Renamed the model configuration field from model to model_name across command-line options, job settings, and result metadata.
    • Updated grid-search workflows, checkpoint selection, logging, and saved metadata to use the new model identifier.
  • Bug Fixes
    • Added compatibility for existing pickles and result files using the former model field, automatically migrating them to model_name.
    • Updated log documentation examples to match current output formatting.
  • Tests
    • Added coverage for legacy result and configuration migration.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a908ad72-f852-4815-a952-f00619c0e83e

📥 Commits

Reviewing files that changed from the base of the PR and between 97203e3 and 865ab91.

📒 Files selected for processing (11)
  • GRID_SEARCH.md
  • run_grid_search.py
  • src/sampleworks/cli/guidance.py
  • src/sampleworks/utils/guidance_script_arguments.py
  • src/sampleworks/utils/guidance_script_utils.py
  • tests/cli/test_guidance_cli.py
  • tests/integration/test_mismatch_integration.py
  • tests/test_run_grid_search.py
  • tests/utils/conftest.py
  • tests/utils/test_guidance_script_arguments.py
  • tests/utils/test_guidance_script_utils.py

📝 Walkthrough

Walkthrough

The PR renames guidance and job model identifiers from model to model_name, updates CLI and grid-search propagation, adds legacy pickle/result migration, and adjusts related tests and documentation.

Changes

Model identifier rename

Layer / File(s) Summary
Configuration contract and CLI wiring
src/sampleworks/utils/guidance_script_arguments.py, src/sampleworks/cli/guidance.py, tests/cli/*, tests/utils/test_guidance_script_arguments.py
GuidanceConfig, JobConfig, and JobResult use model_name; CLI parsing and model-specific configuration wiring are updated, with migration support for legacy pickles.
Job queue and grid-search propagation
run_grid_search.py, src/sampleworks/utils/guidance_script_utils.py, tests/test_run_grid_search.py, tests/utils/*, tests/integration/test_mismatch_integration.py, GRID_SEARCH.md
Worker jobs, model loading, metadata, logs, and grid-search result deduplication use model_name; legacy result records are normalized before saving.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: marcuscollins, k-chrispens, abdelsalam-abbas, dorismai, mag-astera

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Concise and specific; it clearly reflects the model-name rename and distinguishes config values from model objects.
Linked Issues check ✅ Passed The PR renames GuidanceConfig.model and related call sites, preserves --model behavior, and adds backward compatibility and tests as requested.
Out of Scope Changes check ✅ Passed The changes stay focused on the model_name rename, compatibility migration, and related tests/docs; no unrelated code appears introduced.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch xraymemory/issue-289-model-name-main

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the rename of configuration/result fields from modelmodel_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 from model to model_name while keeping --model wired to dest="model_name".
  • Added pickle migration via __setstate__() for GuidanceConfig and JobResult to transparently load legacy model state into model_name.
  • Normalized legacy grid-search results.json run records (modelmodel_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.

Comment on lines 241 to 257
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 marcuscollins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

Rename GuidanceConfig.model to GuidanceConfig.model_name

3 participants