From 419669c1267b790dcd078541e6162470375db9b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:09:35 +0000 Subject: [PATCH 1/7] Initial plan From 4b23b04676ad59284dd480a68ab5c952d0231fe3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:13:12 +0000 Subject: [PATCH 2/7] Add pypsa2smspp integration tests and CI job Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com> --- .github/workflows/test.yml | 39 +++++++++++++++++++++++++++ test/test_pypsa2smspp.py | 54 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 test/test_pypsa2smspp.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4dc8c81..cc10836 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,6 +50,45 @@ jobs: run: | pytest + test_pypsa2smspp: + # Test pypsa2smspp package integration + name: Test pypsa2smspp integration + needs: + - test + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: + - "3.13" + - "3.12" + os: + - ubuntu-latest + env: + MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434 + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 # Needed for setuptools_scm + + - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Install package and dependencies + run: | + python -m pip install --upgrade pip + pip install .[dev] + + - name: Install pypsa2smspp + run: | + pip install pypsa2smspp + + - name: Test pypsa2smspp integration + run: | + pytest test/test_pypsa2smspp.py -v + test_with_smspp: # Test package build in matrix of OS and Python versions name: Test package with SMSpp diff --git a/test/test_pypsa2smspp.py b/test/test_pypsa2smspp.py new file mode 100644 index 0000000..16521ec --- /dev/null +++ b/test/test_pypsa2smspp.py @@ -0,0 +1,54 @@ +"""Tests for pypsa2smspp package integration.""" + +import pytest + + +def test_pypsa2smspp_import(): + """Test that pypsa2smspp can be imported.""" + import pypsa2smspp + + assert hasattr(pypsa2smspp, "Transformation") + assert hasattr(pypsa2smspp, "TransformationConfig") + + +def test_pypsa2smspp_basic_functionality(): + """Test basic pypsa2smspp functionality with a simple network.""" + import pypsa + import pypsa2smspp + + # Create a simple PyPSA network + n = pypsa.Network() + n.add("Bus", "bus0") + n.add("Generator", "gen0", bus="bus0", p_nom=100, marginal_cost=50) + n.add("Load", "load0", bus="bus0", p_set=80) + + # Verify the network was created + assert len(n.buses) == 1 + assert len(n.generators) == 1 + assert len(n.loads) == 1 + + # Test that we can instantiate TransformationConfig + config = pypsa2smspp.TransformationConfig() + assert config is not None + + +def test_pypsa2smspp_config_loading(): + """Test that pypsa2smspp can load its default configuration.""" + import pypsa2smspp + import yaml + import os + + # Find the config file + pypsa2smspp_path = pypsa2smspp.__file__ + config_path = os.path.join( + os.path.dirname(pypsa2smspp_path), "data", "config_default.yaml" + ) + + assert os.path.exists(config_path), f"Config file not found at {config_path}" + + # Load and verify config + with open(config_path) as f: + config = yaml.safe_load(f) + + assert config is not None + assert isinstance(config, dict) From 41ac107b42e37a9d7200970279ca0b16e6228a0d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:15:05 +0000 Subject: [PATCH 3/7] Add explicit permissions to test_pypsa2smspp CI job for security Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com> --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cc10836..00513ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,6 +56,8 @@ jobs: needs: - test runs-on: ${{ matrix.os }} + permissions: + contents: read strategy: fail-fast: false matrix: From f4c23e12e55828d4918885088b7cb0220b183ee8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:16:06 +0000 Subject: [PATCH 4/7] Apply code formatting with ruff Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com> --- test/test_pypsa2smspp.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/test_pypsa2smspp.py b/test/test_pypsa2smspp.py index 16521ec..44ca42d 100644 --- a/test/test_pypsa2smspp.py +++ b/test/test_pypsa2smspp.py @@ -1,7 +1,5 @@ """Tests for pypsa2smspp package integration.""" -import pytest - def test_pypsa2smspp_import(): """Test that pypsa2smspp can be imported.""" From cb80a746ead44f1a61aea18533c8083dffc47074 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:24:44 +0000 Subject: [PATCH 5/7] Update pypsa2smspp CI job to test with full test suite - Limit Python version to 3.13 only as requested - Clone pypsa2smspp repository and run its full test suite - Remove custom integration tests in favor of pypsa2smspp's own tests - This ensures pypsa2smspp tests use the pysmspp package being tested Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com> --- .github/workflows/test.yml | 12 +++++---- .gitignore | 1 + test/test_pypsa2smspp.py | 52 -------------------------------------- 3 files changed, 8 insertions(+), 57 deletions(-) delete mode 100644 test/test_pypsa2smspp.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00513ad..5ec9570 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,6 @@ jobs: matrix: python-version: - "3.13" - - "3.12" os: - ubuntu-latest env: @@ -83,13 +82,16 @@ jobs: python -m pip install --upgrade pip pip install .[dev] - - name: Install pypsa2smspp + - name: Install pypsa2smspp with tests run: | - pip install pypsa2smspp + git clone https://github.com/SPSUnipi/pypsa2smspp.git + cd pypsa2smspp + pip install -e .[dev] - - name: Test pypsa2smspp integration + - name: Test pypsa2smspp package run: | - pytest test/test_pypsa2smspp.py -v + cd pypsa2smspp + pytest -v test_with_smspp: # Test package build in matrix of OS and Python versions diff --git a/.gitignore b/.gitignore index 13c3c76..f1424a8 100644 --- a/.gitignore +++ b/.gitignore @@ -174,3 +174,4 @@ test/temp* # SMS and pypsa files *.nc *.txt +pypsa2smspp/ diff --git a/test/test_pypsa2smspp.py b/test/test_pypsa2smspp.py deleted file mode 100644 index 44ca42d..0000000 --- a/test/test_pypsa2smspp.py +++ /dev/null @@ -1,52 +0,0 @@ -"""Tests for pypsa2smspp package integration.""" - - -def test_pypsa2smspp_import(): - """Test that pypsa2smspp can be imported.""" - import pypsa2smspp - - assert hasattr(pypsa2smspp, "Transformation") - assert hasattr(pypsa2smspp, "TransformationConfig") - - -def test_pypsa2smspp_basic_functionality(): - """Test basic pypsa2smspp functionality with a simple network.""" - import pypsa - import pypsa2smspp - - # Create a simple PyPSA network - n = pypsa.Network() - n.add("Bus", "bus0") - n.add("Generator", "gen0", bus="bus0", p_nom=100, marginal_cost=50) - n.add("Load", "load0", bus="bus0", p_set=80) - - # Verify the network was created - assert len(n.buses) == 1 - assert len(n.generators) == 1 - assert len(n.loads) == 1 - - # Test that we can instantiate TransformationConfig - config = pypsa2smspp.TransformationConfig() - assert config is not None - - -def test_pypsa2smspp_config_loading(): - """Test that pypsa2smspp can load its default configuration.""" - import pypsa2smspp - import yaml - import os - - # Find the config file - pypsa2smspp_path = pypsa2smspp.__file__ - config_path = os.path.join( - os.path.dirname(pypsa2smspp_path), "data", "config_default.yaml" - ) - - assert os.path.exists(config_path), f"Config file not found at {config_path}" - - # Load and verify config - with open(config_path) as f: - config = yaml.safe_load(f) - - assert config is not None - assert isinstance(config, dict) From 20e58a49a710db40cf156a63a586261d98a2bf5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 14:55:34 +0000 Subject: [PATCH 6/7] Move pypsa2smspp test after test_with_smspp and ignore FutureWarnings - Changed test_pypsa2smspp job to depend on test_with_smspp instead of test - Added -W ignore::FutureWarning flag to pytest command to suppress FutureWarnings - This addresses pypsa2smspp tests failing due to FutureWarnings being treated as errors Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com> --- .github/workflows/test.yml | 86 +++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ec9570..fbc927a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,49 +50,6 @@ jobs: run: | pytest - test_pypsa2smspp: - # Test pypsa2smspp package integration - name: Test pypsa2smspp integration - needs: - - test - runs-on: ${{ matrix.os }} - permissions: - contents: read - strategy: - fail-fast: false - matrix: - python-version: - - "3.13" - os: - - ubuntu-latest - env: - MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434 - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 # Needed for setuptools_scm - - - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} - uses: actions/setup-python@v6 - with: - python-version: ${{ matrix.python-version }} - - - name: Install package and dependencies - run: | - python -m pip install --upgrade pip - pip install .[dev] - - - name: Install pypsa2smspp with tests - run: | - git clone https://github.com/SPSUnipi/pypsa2smspp.git - cd pypsa2smspp - pip install -e .[dev] - - - name: Test pypsa2smspp package - run: | - cd pypsa2smspp - pytest -v - test_with_smspp: # Test package build in matrix of OS and Python versions name: Test package with SMSpp @@ -164,3 +121,46 @@ jobs: - name: Test package with SMSpp run: | pytest --force-smspp + + test_pypsa2smspp: + # Test pypsa2smspp package integration + name: Test pypsa2smspp integration + needs: + - test_with_smspp + runs-on: ${{ matrix.os }} + permissions: + contents: read + strategy: + fail-fast: false + matrix: + python-version: + - "3.13" + os: + - ubuntu-latest + env: + MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434 + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 # Needed for setuptools_scm + + - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Install package and dependencies + run: | + python -m pip install --upgrade pip + pip install .[dev] + + - name: Install pypsa2smspp with tests + run: | + git clone https://github.com/SPSUnipi/pypsa2smspp.git + cd pypsa2smspp + pip install -e .[dev] + + - name: Test pypsa2smspp package + run: | + cd pypsa2smspp + pytest -v -W ignore::FutureWarning From 8d52bc91ad0ea5d3b1862b4408cf1bebf92a11ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 18:57:40 +0000 Subject: [PATCH 7/7] Move pypsa2smspp tests as steps in test_with_smspp job - Removed separate test_pypsa2smspp job - Added pypsa2smspp installation and testing as steps in test_with_smspp job - Changed pytest to ignore all warnings with -W ignore (instead of just FutureWarning) - This simplifies the CI workflow by consolidating pypsa2smspp tests with SMSpp tests Co-authored-by: davide-f <67809479+davide-f@users.noreply.github.com> --- .github/workflows/test.yml | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fbc927a..77b218f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -122,38 +122,6 @@ jobs: run: | pytest --force-smspp - test_pypsa2smspp: - # Test pypsa2smspp package integration - name: Test pypsa2smspp integration - needs: - - test_with_smspp - runs-on: ${{ matrix.os }} - permissions: - contents: read - strategy: - fail-fast: false - matrix: - python-version: - - "3.13" - os: - - ubuntu-latest - env: - MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434 - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 # Needed for setuptools_scm - - - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} - uses: actions/setup-python@v6 - with: - python-version: ${{ matrix.python-version }} - - - name: Install package and dependencies - run: | - python -m pip install --upgrade pip - pip install .[dev] - - name: Install pypsa2smspp with tests run: | git clone https://github.com/SPSUnipi/pypsa2smspp.git @@ -163,4 +131,4 @@ jobs: - name: Test pypsa2smspp package run: | cd pypsa2smspp - pytest -v -W ignore::FutureWarning + pytest -v -W ignore