Skip to content

refactor(optim-config): split parsing (reading) from cross-validation - #265

Merged
Juliette-Gerbaux merged 3 commits into
mainfrom
refactor/optim-config-parsing-validation-split
Aug 12, 2026
Merged

refactor(optim-config): split parsing (reading) from cross-validation#265
Juliette-Gerbaux merged 3 commits into
mainfrom
refactor/optim-config-parsing-validation-split

Conversation

@Juliette-Gerbaux

@Juliette-Gerbaux Juliette-Gerbaux commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Process ID

Process: GP-02

Description

Splits gems_craft/optim_config/parsing.py into a reading module and a validation module:

  • parsing.py keeps the Pydantic schema (OptimConfig, ScenarioScopeConfig, ResolutionConfig, etc.) and load_optim_config().
  • New validation.py holds validate_optim_config() and its _check_* helpers, which cross-validate a parsed OptimConfig against a resolved System.

All call sites that imported validate_optim_config directly from .parsing (gems_runner/study/runner.py and three test files) were updated to import it from .validation instead; the package's __init__.py re-exports are unchanged.

Also adds TODO markers where the same reading/validation mixing recurs elsewhere in the codebase, for a future follow-up pass:

  • study/resolve_components.py: consistency_check() and the inline missing-parameter/property checks in _resolve_component()
  • model/resolve_library.py: the _forbid_* expression-validation helpers embedded in the resolution pass
  • study/study.py: Study.check_consistency() duplicates/overlaps with resolve_components.consistency_check() without being consolidated

Impact Analysis

  • Affected modules: optim_config/ (split), plus study/ and model/ (TODO comments only, no behavior change).
  • No solver output values change — this is a pure code-organization refactor; all moved functions are byte-for-byte identical, only import paths changed.

Checklist

  • Unit tests pass (pytest)
  • Type checking passes (mypy)
  • Formatting passes (black, isort)
  • pyproject.toml version bumped if applicable
  • AGENTS.md reviewed for impact and updated if needed

Move validate_optim_config and its _check_* helpers out of parsing.py
into a new validation.py, mirroring the convention of separating
input-reading from business-rule validation. Update all call sites
that imported validate_optim_config directly from .parsing.

Also mark the same mixing pattern with TODOs where it recurs elsewhere
(resolve_components.py, resolve_library.py, study.py) for a future pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Juliette-Gerbaux
Juliette-Gerbaux merged commit f3420ee into main Aug 12, 2026
2 checks passed
@Juliette-Gerbaux
Juliette-Gerbaux deleted the refactor/optim-config-parsing-validation-split branch August 12, 2026 14:36
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.

3 participants