Skip to content

Pydantic-ify RunConfig and nested config dataclasses #52

@jc-macdonald

Description

@jc-macdonald

Summary

Convert the frozen config dataclasses in core_solver.py to Pydantic BaseModel:

  • RunConfig (L194)
  • DtControllerConfig (L148)
  • AdaptiveConfig (L162)
  • OperatorSpecs (L177)

Motivation

These are user-facing configuration objects with no validation at construction time. Validation currently lives downstream in CoreSolver._resolve_run_plan(), meaning invalid configs only surface at solve time. Pydantic adds:

  • Field constraintsmethod validated against MethodName literal (currently str), numeric bounds (ge=0, gt=0) on tolerances, safety factors, dt limits.
  • Serialization — YAML/JSON round-tripping for config persistence and reproducibility.
  • Immutabilitymodel_config = ConfigDict(frozen=True) replaces @dataclass(frozen=True).
  • Consistency — Matches the flepimop2 provider config (OpEngineEngineConfig) which is already Pydantic.

Scope

  • Convert 4 dataclasses → Pydantic BaseModel with frozen=True
  • Add field validators / constraints matching current downstream checks
  • Update _resolve_run_plan() to rely on config-level validation
  • Update all tests constructing these objects

Constraints

  • Must not change RunPlan (internal-only, never user-constructed)
  • Must not change mutable parameter bundles (StepIO, ImplicitStageParams, etc.) — hot-path structures
  • Must pass ruff check --preview and mypy --strict

Related

Metadata

Metadata

Assignees

Labels

architectureStructural or design-level changesrefactorCode reorganization without behavior change

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions