refactor: typed pipeline spine + SimulationBackend protocol (R1, R2);…#112
Merged
Merged
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… 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:
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