Repository navigation
feat: PyPSA-EUR pipeline consolidation, fr225_400 dataset, full test coverage - #112
Merged
Merged
Conversation
- Rewrite convert_pypsa_to_xiidm.py into 5-step pipeline with PipelineContext: load → network → calibrate → n1verify → metadata CLI options: --steps, --from-step, --skip-n1 for selective execution - Parameterize fetch_osm_names.py with --voltages, --output-dir, --cache-from - Add regenerate_grid_layout.py for standalone layout regeneration - Add test_regenerate_grid_layout.py with 37 tests (Mercator math, key matching, cross-network consistency) - Regenerate both grid_layout.json files with correct Mercator projection and VL key matching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…25_400 Move all PyPSA-EUR scripts under scripts/pypsa_eur/, add a build_pipeline.py orchestrator that chains the five conversion steps, and extract the thermal calibration + N-1 overload reporting into their own tools. Drop hardcoded /home/marotant/... paths so everything works from any checkout. Tests are consolidated behind a shared conftest.py that exposes the network, contingency, and layout fixtures plus an expected_counts derivation — so the suite is network-agnostic and runs against pypsa_eur_fr225_400 (new default) or pypsa_eur_fr400 via --pypsa-network. New unit-test files exercise build_pipeline.py, calibrate_thermal_limits.py, and generate_n1_overloads.py without depending on the full pypowsybl stack. pypsa_eur_fr225_400 dataset (1196 buses, 1861 lines, 361 couplers, 2351 actions, 130% N-1 peak) is force-added so the canonical network ships with the repo. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…k-scripts # Conflicts: # scripts/convert_pypsa_to_xiidm.py # scripts/test_grid_layout.py
Resolves ruff F541 on four f-strings without placeholders in the PyPSA-EUR helper scripts, and adds the missing `import sys` in verify_detailed_topology (F821) so its final `sys.exit` works. https://claude.ai/code/session_016ovnGnHPKUJ9jxdgiZRCec
…Mh5N Remove unnecessary f-string prefixes from static strings
3 tasks
marota
added a commit
that referenced
this pull request
May 5, 2026
Sixteen merged PRs (#112–#127) plus the polish landed on ``claude/interactive-overflow-analysis``. Headlined by the interactive overflow analysis tab, the PyPSA-EUR European-wide grid pipeline, and the design-token migration. See CHANGELOG.md section 0.7.0 for the full entry; README badge + reference table bumped accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
Summary
Consolidates the PyPSA-EUR OSM→XIIDM conversion pipeline into
scripts/pypsa_eur/, ships the canonicalpypsa_eur_fr225_400dataset, and adds end-to-end test coverage so the pipeline can be iterated on without regressing silently.Three logical changes, in three commits plus a merge from
main:grid_layout.jsonwas produced with inconsistent projection / VL key assumptions. Regenerated with correct Mercator math so layouts line up with the XIIDM VL IDs.convert_pypsa_to_xiidm.pyis rewritten as a 5-step pipeline with a sharedPipelineContext(load → network → calibrate → n1verify → metadata).fetch_osm_names.pyis parameterized with--voltages,--output-dir,--cache-from. Newregenerate_grid_layout.py+ 37-test suite covers Mercator math, key matching, and cross-network consistency.scripts/pypsa_eur/, a top-levelbuild_pipeline.pyorchestrator chains the five steps, and thermal calibration + N-1 overload reporting are extracted into their own tools. Hardcoded/home/marotant/...paths are gone.Pipeline layout (post-merge)
Top-level entrypoint:
python scripts/pypsa_eur/build_pipeline.py \ --voltages 225,400 \ --n1-peak-pct 130 \ --min-branches 3 # → writes to data/pypsa_eur_fr225_400/ by defaultTest coverage
All tests live under
scripts/pypsa_eur/and share a singleconftest.pyso no file re-defines the network / contingencies / layout fixtures. Counts are derived from artifacts on disk via anexpected_countsfixture — nothing is hard-coded to 398 or 192 anymore, so the suite works on bothpypsa_eur_fr400andpypsa_eur_fr225_400via--pypsa-network <name>.test_pipeline.pytest_n1_calibration.pytest_grid_layout.pytest_regenerate_grid_layout.pytest_build_pipeline.py--steps,--from-step,--skip-osm), arg propagation, failure handling,--helptest_calibrate_thermal_limits.py_patch_xiidm_limitsregex, XML parseability,_overload_fractioncountingtest_generate_n1_overloads.py_get_line_limits_from_xml, module constants, CLI surface207 passedon the non-slow subset againstpypsa_eur_fr225_400.pypsa_eur_fr225_400 dataset
Force-added (the
data/rule in.gitignorewould otherwise drop it) so the canonical network ships with the repo:actions.json,bus_id_mapping.json,grid_layout.json,line_id_names.json,n1_overload_contingencies.json,network.xiidm,osm_names.json,vl_next_node.jsonMerge note
This branch is behind main by 138 non-pypsa commits; merged
origin/mainwith-X oursso our pypsa work wins on the five overlap points (data/pypsa_eur_fr400/actions.json,data/pypsa_eur_fr400/network.xiidm,docs/data/pypsa-eur-osm-to-xiidm.md,scripts/pypsa_eur/build_pypsa_eur_network.py), and took our side on two modify/delete conflicts (scripts/convert_pypsa_to_xiidm.py,scripts/test_grid_layout.py— both moved toscripts/pypsa_eur/). Non-pypsa main changes (backend refactor, frontend tests, docs reorganization, parity scripts, code-quality gate, …) flow through unchanged.Test plan
pytest scripts/pypsa_eur/ -m "not slow"— expect 207 passedpytest scripts/pypsa_eur/ -m slow— expect all passing (pypowsybl-heavy, ~several minutes)python scripts/pypsa_eur/build_pipeline.py --help— expect usage with--voltages,--steps,--from-step,--skip-osm,--n1-peak-pct,--min-branchespython scripts/pypsa_eur/build_pipeline.py --voltages 400 --steps 5on an existingdata/pypsa_eur_fr400/— expect freshn1_overload_contingencies.jsondata/pypsa_eur_fr225_400/network.xiidmvia the React UI, run a single contingency, confirm overloads render🤖 Generated with Claude Code