refactor(dc_solver): start importer-backed preprocessing in powsybl example grids#510
Draft
spetznick-elia with Copilot wants to merge 3 commits into
Draft
refactor(dc_solver): start importer-backed preprocessing in powsybl example grids#510spetznick-elia with Copilot wants to merge 3 commits into
spetznick-elia with Copilot wants to merge 3 commits into
Conversation
Copilot
AI
changed the title
[WIP] Start implementation of refactor for data saving
refactor(dc_solver): start importer-backed preprocessing in powsybl example grids
May 28, 2026
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.
Checklist
Please check if the PR fulfills these requirements:
Does this PR already have an issue describing the problem?
Tracked separately by the issue workflow.
What is the new behavior (if this is a feature change)?
Example-grid generation that previously relied on direct
np.savemask writes now starts an importer-backed preprocessing path for powsybl examples, while preserving existing mask semantics for these synthetic grids.Powsybl preprocessing entrypoint
_run_importer_preprocessing_for_powsybl(...)inexample_grids.py.UcteImporterParameters/CgmesImporterParameters(backend-appropriate shape) to invokepreprocessing.convert_file(...).Mask persistence refactor
np.save(...)in:case30_with_psts_powsyblthree_node_pst_example_folder_powsyblsave_numpy_filesystem(...)for mask persistence in these paths.Focused regression coverage
test_three_node_pst_example_folder_powsyblto assert relevant-node mask behavior remains aligned with PST-connected nodes.Does this PR introduce a breaking change?
Original prompt
Start implementation
The user has attached the following file paths as relevant context:
- .github/copilot-instructions.md
[Chronological Review: The conversation began with the user requesting a refactor of functions that manually save data using `np.save`. The user specifically mentioned the function `parallel_pst_data_folder` as an example for this refactor. The user aimed to replace manual saving with a more structured approach using the `preprocessing.convert_file` function. Following this, the user requested a plan for refactoring all relevant functions. The most recent command was to start the implementation of the refactor.][Intent Mapping:
[Technical Inventory:
parallel_pst_data_folder: A function that creates a preprocessed folder forparallel_pst_example(), runs the importer and preprocessing, and saves the network data.preprocessing.convert_file: A function intended to replace manual saving of data.numpy,pypowsybl,pathlib, and custom modules related totoop_engine_dc_solver.][Code Archaeology:
parallel_pst_data_folder: This function was discussed in detail, including its parameters and return type.case30_with_psts_pandapower,case30_with_psts_powsybl,node_breaker_folder_powsybl,three_node_pst_example_folder_powsybl, andcomplex_grid_battery_hvdc_svc_3w_trafo_data_folder. Each of these functions involves similar data handling and saving processes.][Progress Assessment:
[Context Validation: All necessary context for continuing the refactor has been captured, including specific functions to modify and the intended use of
preprocessing.convert_file.][Recent Commands Analysis:
parallel_pst_data_folderfunction and related functions.1. Conversation Overview: - Primary Objectives: The user requested to refactor functions that rely on manual `np.save` for saving masks to disk, specifically mentioning the function `parallel_pst_data_folder` as an example. The user emphasized the need to use proper parameters for powsybl and pandapower grids. - Session Context: The conversation flowed from identifying the need for refactoring to outlining specific functions that require changes, culminating in a request to start the implementation. - User Intent Evolution: The user initially focused on identifying functions for refactoring and then moved to initiate the implementation phase.- Technical Foundation:
- Libraries:
- Codebase Status:
- Purpose: Preprocesses data for
- Current State: The function is set to be refactored to use
- Key Code Segments: The function includes loading the network, running a DC load flow, and saving the grid file.
- Dependencies: Relies on
- Problem Resolution:
- Issues Encountered: Manual saving methods in various functions.
- Solutions Implemented: The user has proposed a refactor to use
- Debugging Context: No specific debugging issues were mentioned; the focus is on refactoring.
- Lessons Learned: The need for a structured approach to saving data has been identified.
- Progress Tracking:
- Completed Tasks: The user has outlined the need for refactoring and provided an example function.
- Partially Complete Work: The implementation of the refactor is pending.
- Validated Outcomes: No specific outcomes have been validated yet as the implementation has just begun.
- Active Work State:
- Current Focus: The user is focused on implementing the refactor of the
- Recent Context: The l...
parallel_pst_data_folder: A function that preprocesses data forparallel_pst_example(), runs the importer, and saves the network data.preprocessing.convert_file: A function intended to replace manual saving of data.numpy,pypowsybl,pathlib, and custom modules related totoop_engine_dc_solver.parallel_pst_data_folder:parallel_pst_example().preprocessing.convert_file.pypowsyblfor load flow calculations andpreprocessingfor data conversion.preprocessing.convert_file.parallel_pst_data_folderfunction and related functions.Created from VS Code.