Skip to content

Commit 2256e00

Browse files
authored
updated power-grid-model-io and removed skip/workaround for issue (#3023)
* updated power-grid-model-io and removed skip/workaround for issue * moved pgm from all to dev since pgm is only supported by python >= 3.12 * updated github_test_action.yml to avoid pgm installation in unsupported python versions * added importskip for pgm and pgm-io * fixed uv sync command * marked pgm and dev only supported by python 3.12 * added pgm to the tutorial tests * removed unused dependencies from test pipeline
1 parent d7a9cb0 commit 2256e00

4 files changed

Lines changed: 19 additions & 49 deletions

File tree

.github/workflows/github_test_action.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,32 @@ jobs:
4141
with:
4242
python-version: ${{ matrix.python-version }}
4343
- name: Install dependencies
44+
if: ${{ (matrix.python-version != '3.10') && (matrix.python-version != '3.11') }}
4445
run: |
45-
uv sync --extra dev
46+
uv sync --extra all --extra test --extra pandamodels --extra pgm
47+
uv pip install pytest-split
48+
uv pip uninstall juliacall
49+
- name: Install dependencies
50+
if: ${{ (matrix.python-version == '3.10') || (matrix.python-version == '3.11') }}
51+
run: |
52+
uv sync --extra all --extra test --extra pandamodels
4653
uv pip install pytest-split
4754
uv pip uninstall juliacall
48-
# if ${{ matrix.python-version == '3.10' }}; then uv pip install pypower; fi
49-
# if ${{ matrix.python-version != '3.10' }}; then uv pip install numba; fi
50-
# if ${{ matrix.python-version == '3.14' }}; then uv pip install lightsim2grid; fi
51-
# if ${{ matrix.python-version == '3.13' }}; then uv pip install lightsim2grid; fi
5255
- name: List of installed packages
5356
run: |
5457
uv pip list
5558
- name: Test with pytest
56-
if: ${{ matrix.python-version != '3.10' }}
59+
if: ${{ matrix.python-version != '3.12' }}
5760
run: |
5861
uv run pytest --splits 2 --group ${{ matrix.group }} $IGNORES
5962
- name: Test with pytest, Codecov and Coverage
60-
if: ${{ matrix.python-version == '3.10' }}
63+
if: ${{ matrix.python-version == '3.12' }} # collecting on 3.12 (oldest version where pgm is included)
6164
run: |
6265
uv pip install pytest-cov numpy~=1.26
6366
uv run pytest --cov=./ --cov-report=xml --splits 2 --group ${{ matrix.group }} $IGNORES
6467
cp ./coverage.xml ./coverage-${{ matrix.group }}.xml
6568
- name: Upload coverage as artifact
66-
if: ${{ matrix.python-version == '3.10' }}
69+
if: ${{ matrix.python-version == '3.12' }}
6770
uses: actions/upload-artifact@v7
6871
with:
6972
name: coverage-${{ matrix.group }}
@@ -89,7 +92,7 @@ jobs:
8992
python-version: '3.14'
9093
- name: Install dependencies
9194
run: |
92-
uv sync --extra dev
95+
uv sync --extra all --extra test --extra pandamodels --extra pgm
9396
uv pip uninstall juliacall
9497
uv pip install pytest-cov pytest-split
9598
- name: List of installed packages
@@ -377,7 +380,7 @@ jobs:
377380
- uses: actions/checkout@v6
378381
- name: Install dependencies
379382
run: |
380-
python -m pip install -e .[all,tutorials,test]
383+
python -m pip install -e .[all,pgm,tutorials,test]
381384
- name: List all installed packages
382385
run: |
383386
python -m pip list
@@ -397,7 +400,7 @@ jobs:
397400
- uses: actions/checkout@v6
398401
- name: Install dependencies
399402
run: |
400-
python -m pip install -e .[all,tutorials,test]
403+
python -m pip install -e .[all,pgm,tutorials,test]
401404
- name: List all installed packages
402405
run: |
403406
python -m pip list

pandapower/test/loadflow/test_runpp_pgm.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@
55

66
from pandapower.create import create_bus, create_ext_grid, create_load, create_switch, create_sgen, create_line
77
from pandapower.network import pandapowerNet
8-
from pandapower.create._utils import add_column_to_df
98
from pandapower.run import runpp_pgm
109
from pandapower.test.consistency_checks import runpp_pgm_with_consistency_checks, runpp_pgm_3ph_with_consistency_checks
1110

12-
try:
13-
import power_grid_model
14-
15-
PGM_IMPORTED = True
16-
except ImportError:
17-
PGM_IMPORTED = False
11+
pytest.importorskip("power_grid_model")
12+
pytest.importorskip("power_grid_model_io")
1813

1914

2015
@pytest.mark.parametrize("consistency_fn", [runpp_pgm_with_consistency_checks, runpp_pgm_3ph_with_consistency_checks])
21-
@pytest.mark.skipif(not PGM_IMPORTED, reason="requires power_grid_model")
2216
def test_minimal_net_pgm(consistency_fn):
2317
# tests corner-case when the grid only has 1 bus and an ext-grid
2418
net = pandapowerNet(name="test_minimal_net_pgm")
@@ -27,8 +21,6 @@ def test_minimal_net_pgm(consistency_fn):
2721
consistency_fn(net)
2822

2923
create_load(net, b, p_mw=0.1)
30-
# FIXME: temporary skip for pgm converter due to pd.NA
31-
pytest.skip("PGM's _get_pp_attr has an error when handling pandapower 4 networks. (pd.NA dtype support missing)")
3224
consistency_fn(net)
3325

3426
b2 = create_bus(net, 110)
@@ -37,7 +29,6 @@ def test_minimal_net_pgm(consistency_fn):
3729
consistency_fn(net)
3830

3931

40-
@pytest.mark.skipif(not PGM_IMPORTED, reason="requires power_grid_model")
4132
def test_runpp_pgm__invalid_algorithm():
4233
net = pandapowerNet(name="test_runpp_pgm__invalid_algorithm")
4334
with pytest.raises(
@@ -48,7 +39,6 @@ def test_runpp_pgm__invalid_algorithm():
4839

4940

5041
@patch("pandapower.run.logger")
51-
@pytest.mark.skipif(not PGM_IMPORTED, reason="requires power_grid_model")
5242
def test_runpp_pgm__internal_pgm_error(mock_logger: MagicMock):
5343
net = pandapowerNet(name="test_runpp_pgm__internal_pgm_error")
5444
b1 = create_bus(net, 110)
@@ -69,7 +59,6 @@ def test_runpp_pgm__internal_pgm_error(mock_logger: MagicMock):
6959

7060

7161
@patch("pandapower.run.logger")
72-
@pytest.mark.skipif(not PGM_IMPORTED, reason="requires power_grid_model")
7362
def test_runpp_pgm__validation_fail(mock_logger: MagicMock):
7463
net = pandapowerNet(name="test_runpp_pgm__validation_fail")
7564
create_bus(net, -110, index=123)

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ test = ["pytest~=9.0", "nbmake~=1.5", "pytest-timeout", "pytest-split"]
7878
performance = ["ortools~=9.14", "numba~=0.61", "lightsim2grid~=0.13.0"]
7979
fileio = ["xlsxwriter~=3.2", "openpyxl~=3.1", "cryptography~=46.0", "geopandas~=1.1", "psycopg~=3.2", "lxml~=6.0"]
8080
converter = ["matpowercaseframes~=1.1", "lxml~=6.0"]
81-
pgm = ["power-grid-model-io~=1.2"]
81+
pgm = ["power-grid-model-io~=1.3.87; python_version >= '3.12'"]
8282
control = ["shapely~=2.1"]
8383
pandamodels = ["juliacall~=0.9"]
8484
tutorials = ["julia", "juliacall~=0.9", "seaborn", "jupyter", "notebook"]
@@ -96,8 +96,8 @@ typing = [
9696
"matplotlib~=3.10"
9797
]
9898

99-
all = ["pandapower[plotting,performance,fileio,converter,pgm,control]"]
100-
dev = ["pandapower[all,docs,test,typing,pandamodels,tutorials]"]
99+
all = ["pandapower[plotting,performance,fileio,converter,control]"]
100+
dev = ["pandapower[all,docs,test,typing,pandamodels,tutorials,pgm]; python_version >= '3.12'"]
101101
# "shapely", "pyproj", "Pyogrio" are dependencies of geopandas and should be already available ("Fiona" got dropped)
102102
# "hashlib", "zlib", "base64" produce install problems, so they are not included
103103

tutorials/power-grid-model_powerflow.ipynb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,6 @@
5151
"A powerflow can be run using power-grid-model for calculation by using the `pp.runpp_pgm` function. The function has its own arguments different from `pp.runpp()`"
5252
]
5353
},
54-
{
55-
"metadata": {},
56-
"cell_type": "code",
57-
"source": [
58-
"# TODO: remove this cell once power_grid_model_io fixes the issue #422\n",
59-
"strings = {\n",
60-
" \"bus\": [\"name\", \"type\"],\n",
61-
" \"load\": [\"name\", \"type\"],\n",
62-
" \"sgen\": [\"name\"],\n",
63-
" \"switch\": [\"type\"],\n",
64-
" \"shunt\": [\"name\"],\n",
65-
" \"line\": [\"name\", \"std_type\", \"type\"],\n",
66-
" \"trafo\": [\"name\", \"std_type\", \"vector_group\", \"tap_side\"],\n",
67-
"}\n",
68-
"for table, columns in strings.items():\n",
69-
" for col in columns:\n",
70-
" net[table][col] = net[table][col].astype(object)"
71-
],
72-
"id": "c09670c23aca4a6",
73-
"outputs": [],
74-
"execution_count": null
75-
},
7654
{
7755
"cell_type": "code",
7856
"id": "456b50b1",

0 commit comments

Comments
 (0)