Skip to content

refactor: typed pipeline spine + SimulationBackend protocol (R1, R2);…#112

Merged
marota merged 1 commit into
ainetus:mainfrom
marota:claude/expert-op4grid-refactor-bqy6jm
Jul 3, 2026
Merged

refactor: typed pipeline spine + SimulationBackend protocol (R1, R2);…#112
marota merged 1 commit into
ainetus:mainfrom
marota:claude/expert-op4grid-refactor-bqy6jm

Conversation

@marota

@marota marota commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

… release 0.2.7

Behaviour-preserving restructure of the analysis entry point per the 2026-07 code review's deep revisions R1 and R2. Verified byte-identical prioritized-action output on the bare-env golden plus all pypowsybl integration tests; full non-slow suite green (the single grid2op golden delta is a lightsim2grid/grid2op version mismatch that reproduces identically on the pre-refactor code).

R1 - typed pipeline spine + backend protocol:

  • backends.py (new): SimulationBackend protocol + Grid2opBackend / PypowsyblBackend holding fast_mode as constructor state. Replaces the 18 _grid2op/pypowsybl delegation wrappers, the 8 context function pointers, the is_pypowsybl call-site forks, and the discoverer.* monkey-patching.
  • pipeline.py (new): AnalysisContext / AnalysisResult dataclasses (dict-compatible via DictCompatMixin) replace the ~41-key context dict and the untyped result dict. run_analysis_step1 now returns AnalysisContext | AnalysisResult instead of the (Optional, Optional) sentinel tuple.
  • discovery: shared-baseline routing moved into ActionDiscoverer via constructor flags + a real DiscovererBase._shared_baseline_check method (no more monkey-patching the live instance).
  • reassessment now emits the typed SimulatedAction card.

R2 - split main.py into cli.py + pipeline.py; move _run_expert_discovery under models/_expert_discovery.py. Dependency direction becomes cli -> pipeline -> models -> action_evaluation/graph_analysis -> utils, dissolving all three import cycles. main.py remains a thin re-export facade so every from expert_op4grid_recommender.main import ... still resolves. scripts/benchmark_pipeline.py updated for the new return shape.

Release 0.2.7 (CHANGELOG [0.2.7]); adds tests/test_typed_pipeline_spine.py covering the dict-compat, backend-flag, shared-baseline-routing, import- layering and facade contracts.

Claude-Session: https://claude.ai/code/session_01LGzwaP2SnQCbLKo4ZNuwSg

… release 0.2.7

Behaviour-preserving restructure of the analysis entry point per the
2026-07 code review's deep revisions R1 and R2. Verified byte-identical
prioritized-action output on the bare-env golden plus all pypowsybl
integration tests; full non-slow suite green (the single grid2op golden
delta is a lightsim2grid/grid2op version mismatch that reproduces
identically on the pre-refactor code).

R1 - typed pipeline spine + backend protocol:
- backends.py (new): SimulationBackend protocol + Grid2opBackend /
  PypowsyblBackend holding fast_mode as constructor state. Replaces the
  18 *_grid2op/*_pypowsybl delegation wrappers, the 8 context function
  pointers, the is_pypowsybl call-site forks, and the discoverer._*
  monkey-patching.
- pipeline.py (new): AnalysisContext / AnalysisResult dataclasses
  (dict-compatible via DictCompatMixin) replace the ~41-key context dict
  and the untyped result dict. run_analysis_step1 now returns
  AnalysisContext | AnalysisResult instead of the (Optional, Optional)
  sentinel tuple.
- discovery: shared-baseline routing moved into ActionDiscoverer via
  constructor flags + a real DiscovererBase._shared_baseline_check
  method (no more monkey-patching the live instance).
- reassessment now emits the typed SimulatedAction card.

R2 - split main.py into cli.py + pipeline.py; move _run_expert_discovery
under models/_expert_discovery.py. Dependency direction becomes
cli -> pipeline -> models -> action_evaluation/graph_analysis -> utils,
dissolving all three import cycles. main.py remains a thin re-export
facade so every `from expert_op4grid_recommender.main import ...` still
resolves. scripts/benchmark_pipeline.py updated for the new return shape.

Release 0.2.7 (CHANGELOG [0.2.7]); adds tests/test_typed_pipeline_spine.py
covering the dict-compat, backend-flag, shared-baseline-routing, import-
layering and facade contracts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGzwaP2SnQCbLKo4ZNuwSg
Signed-off-by: Antoine Marot <amarot91@gmail.com>
@marota marota merged commit 5d43e14 into ainetus:main Jul 3, 2026
4 checks passed
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.

1 participant