Skip to content

refactor(dc_solver): start importer-backed preprocessing in powsybl example grids#510

Draft
spetznick-elia with Copilot wants to merge 3 commits into
mainfrom
copilot/start-implementation-again
Draft

refactor(dc_solver): start importer-backed preprocessing in powsybl example grids#510
spetznick-elia with Copilot wants to merge 3 commits into
mainfrom
copilot/start-implementation-again

Conversation

Copilot AI commented May 28, 2026

Copy link
Copy Markdown
Contributor

Checklist

Please check if the PR fulfills these requirements:

  • PR Title follows conventional commit messages
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • All commits in this PR are DCO signed-off (see CONTRIBUTING.md)

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.save mask writes now starts an importer-backed preprocessing path for powsybl examples, while preserving existing mask semantics for these synthetic grids.

  • Powsybl preprocessing entrypoint

    • Added _run_importer_preprocessing_for_powsybl(...) in example_grids.py.
    • Uses UcteImporterParameters/CgmesImporterParameters (backend-appropriate shape) to invoke preprocessing.convert_file(...).
    • Handles unsupported synthetic-grid cases gracefully and falls back to explicit example mask writes.
  • Mask persistence refactor

    • Replaced direct np.save(...) in:
      • case30_with_psts_powsybl
      • three_node_pst_example_folder_powsybl
    • Now uses save_numpy_filesystem(...) for mask persistence in these paths.
  • Focused regression coverage

    • Added test_three_node_pst_example_folder_powsybl to assert relevant-node mask behavior remains aligned with PST-connected nodes.
_run_importer_preprocessing_for_powsybl(folder=folder, grid_file_path=grid_file_path, data_type="ucte")
save_numpy_filesystem(filesystem, masks_path / NETWORK_MASK_NAMES["relevant_subs"], rel_sub_mask)
save_numpy_filesystem(filesystem, masks_path / NETWORK_MASK_NAMES["trafo_pst_controllable"], trafo_mask)

Does this PR introduce a breaking change?

  • Yes
  • No
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:

  • User Request 1: "I want to refactor the example grid that still rely on manual use of np.save to save masks to disk."
  • User Request 2: "Make sure to use proper parameters depending on whether it is a powsybl or a pandapower grid."
  • User Request 3: "Start implementation."]

[Technical Inventory:

  • Function parallel_pst_data_folder: A function that creates a preprocessed folder for parallel_pst_example(), runs the importer and preprocessing, and saves the network data.
  • Function preprocessing.convert_file: A function intended to replace manual saving of data.
  • Libraries: numpy, pypowsybl, pathlib, and custom modules related to toop_engine_dc_solver.]

[Code Archaeology:

  • parallel_pst_data_folder: This function was discussed in detail, including its parameters and return type.
  • Other functions mentioned: case30_with_psts_pandapower, case30_with_psts_powsybl, node_breaker_folder_powsybl, three_node_pst_example_folder_powsybl, and complex_grid_battery_hvdc_svc_3w_trafo_data_folder. Each of these functions involves similar data handling and saving processes.]

[Progress Assessment:

  • Completed: The user has outlined the need for refactoring and provided an example function.
  • Pending: The actual implementation of the refactor across all relevant functions.]

[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:

  • Last Agent Commands: The user executed a command to "Start implementation."
  • Tool Results Summary: No specific tool results were returned as the command was to initiate implementation.
  • Pre-Summary State: The agent was preparing to implement the refactor of the parallel_pst_data_folder function and related functions.
  • Operation Context: The command was executed in the context of refactoring functions that currently use manual saving methods to utilize a more structured approach.]
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.
  1. Technical Foundation:
  • parallel_pst_data_folder: A function that preprocesses data for parallel_pst_example(), runs the importer, and saves the network data.
  • preprocessing.convert_file: A function intended to replace manual saving of data.
  • Libraries: numpy, pypowsybl, pathlib, and custom modules related to toop_engine_dc_solver.
  1. Codebase Status:
  • parallel_pst_data_folder:
    • Purpose: Preprocesses data for parallel_pst_example().
    • Current State: The function is set to be refactored to use preprocessing.convert_file.
    • Key Code Segments: The function includes loading the network, running a DC load flow, and saving the grid file.
    • Dependencies: Relies on pypowsybl for load flow calculations and preprocessing for data conversion.
  1. Problem Resolution:
  • Issues Encountered: Manual saving methods in various functions.
  • Solutions Implemented: The user has proposed a refactor to use preprocessing.convert_file.
  • 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.
  1. 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.
  1. Active Work State:
  • Current Focus: The user is focused on implementing the refactor of the parallel_pst_data_folder function and related functions.
  • Recent Context: The l...

Created from VS Code.

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
Copilot AI requested a review from spetznick-elia May 28, 2026 09:56
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.

2 participants