From 7db9daf2012bd35224342cb014337aa18bd87036 Mon Sep 17 00:00:00 2001 From: joda9 Date: Mon, 8 Jul 2024 17:07:55 +0200 Subject: [PATCH 1/8] update setup.py to newest pypsa and pyomo versions --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4f570f74..0d83f01f 100644 --- a/setup.py +++ b/setup.py @@ -50,10 +50,10 @@ def read(fname): "plotly", "pydot", "pygeos", - "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release + # "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release "pypower", "pyproj >= 3.0.0", - "pypsa >= 0.17.0, <= 0.20.1", + "pypsa", "pyyaml", "saio", "scikit-learn <= 1.1.1", From c400c804a791ef78d930349c35f42b37e34f2c79 Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 11:33:04 +0200 Subject: [PATCH 2/8] add pytest.mark.oedbtest for failing tests due to oedb error --- tests/conftest.py | 10 ++++++++++ tests/io/test_generators_import.py | 4 ++++ tests/io/test_timeseries_import.py | 2 ++ tests/network/test_timeseries.py | 1 + tests/test_edisgo.py | 1 + tests/test_examples.py | 2 ++ tests/tools/test_tools.py | 1 + 7 files changed, 21 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 6809eb81..8dedbc6c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -57,6 +57,9 @@ def pytest_addoption(parser): default=False, help="run tests that only work locally", ) + parser.addoption( + "--runoedbtest", action="store_true", default=False, help="Run OEDB tests" + ) def pytest_collection_modifyitems(config, items): @@ -75,3 +78,10 @@ def pytest_collection_modifyitems(config, items): for item in items: if "runonlinux" in item.keywords: item.add_marker(skip_windows) + if config.getoption("--runoedbtest"): + # If the --runoedbtest option is specified, do not skip any tests + return + skip_oedbtest = pytest.mark.skip(reason="Need --runoedbtest option to run") + for item in items: + if "oedbtest" in item.keywords: + item.add_marker(skip_oedbtest) diff --git a/tests/io/test_generators_import.py b/tests/io/test_generators_import.py index 9adfdde1..51ee4b5e 100644 --- a/tests/io/test_generators_import.py +++ b/tests/io/test_generators_import.py @@ -484,6 +484,7 @@ class TestGeneratorsImportOEDB: """ @pytest.mark.slow + @pytest.mark.oedbtest def test_oedb_legacy_without_timeseries(self): edisgo = EDisGo( ding0_grid=pytest.ding0_test_network_2_path, @@ -497,6 +498,7 @@ def test_oedb_legacy_without_timeseries(self): assert np.isclose(edisgo.topology.generators_df.p_nom.sum(), 20.18783) @pytest.mark.slow + @pytest.mark.oedbtest def test_oedb_legacy_with_worst_case_timeseries(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_2_path) edisgo.set_time_series_worst_case_analysis() @@ -568,6 +570,7 @@ def test_oedb_legacy_with_worst_case_timeseries(self): # :, new_solar_gen.name] / new_solar_gen.p_nom).all() @pytest.mark.slow + @pytest.mark.oedbtest def test_oedb_legacy_with_timeseries_by_technology(self): timeindex = pd.date_range("1/1/2012", periods=3, freq="H") ts_gen_dispatchable = pd.DataFrame( @@ -647,6 +650,7 @@ def test_oedb_legacy_with_timeseries_by_technology(self): # :, new_solar_gen.name] / new_solar_gen.p_nom).all() @pytest.mark.slow + @pytest.mark.oedbtest def test_target_capacity(self): edisgo = EDisGo( ding0_grid=pytest.ding0_test_network_2_path, diff --git a/tests/io/test_timeseries_import.py b/tests/io/test_timeseries_import.py index 93825e9a..2bae3cf2 100644 --- a/tests/io/test_timeseries_import.py +++ b/tests/io/test_timeseries_import.py @@ -59,6 +59,7 @@ def test__timeindex_helper_func(self): assert_index_equal(ind, given_index) assert_index_equal(ind_full, timeindex) + @pytest.mark.oedbtest def test_feedin_oedb_legacy(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_path) timeindex = pd.date_range("1/1/2010", periods=3000, freq="H") @@ -86,6 +87,7 @@ def test_feedin_oedb(self): assert feedin_df.shape == (6, 4) assert_index_equal(feedin_df.index, timeindex) + @pytest.mark.oedbtest def test_load_time_series_demandlib(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_path) timeindex = pd.date_range("1/1/2018", periods=7000, freq="H") diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 2c05eda4..3818aaf3 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1235,6 +1235,7 @@ def test_worst_case_storage_units(self): ) @pytest.mark.slow + @pytest.mark.oedbtest def test_predefined_fluctuating_generators_by_technology(self): timeindex = pd.date_range("1/1/2011 12:00", periods=2, freq="H") self.edisgo.timeseries.timeindex = timeindex diff --git a/tests/test_edisgo.py b/tests/test_edisgo.py index e0379bd5..dbfa03a3 100755 --- a/tests/test_edisgo.py +++ b/tests/test_edisgo.py @@ -382,6 +382,7 @@ def test_to_graph(self): ) @pytest.mark.slow + @pytest.mark.oedbtest def test_generator_import(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_2_path) edisgo.import_generators("nep2035") diff --git a/tests/test_examples.py b/tests/test_examples.py index 8e31d88d..9f0a862e 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -26,6 +26,7 @@ def test_plot_example_ipynb(self): assert result.exec_error is None @pytest.mark.slow + @pytest.mark.oedbtest def test_electromobility_example_ipynb(self): path = os.path.join(self.examples_dir_path, "electromobility_example.ipynb") notebook = pytest_notebook.notebook.load_notebook(path=path) @@ -39,6 +40,7 @@ def test_electromobility_example_ipynb(self): assert result.exec_error is None @pytest.mark.slow + @pytest.mark.oedbtest def test_edisgo_simple_example_ipynb(self): path = os.path.join(self.examples_dir_path, "edisgo_simple_example.ipynb") notebook = pytest_notebook.notebook.load_notebook(path=path) diff --git a/tests/tools/test_tools.py b/tests/tools/test_tools.py index 606c60d8..40c34a63 100644 --- a/tests/tools/test_tools.py +++ b/tests/tools/test_tools.py @@ -168,6 +168,7 @@ def test_determine_bus_voltage_level(self): assert tools.determine_bus_voltage_level(self.edisgo, bus_voltage_level_6) == 6 assert tools.determine_bus_voltage_level(self.edisgo, bus_voltage_level_7) == 7 + @pytest.mark.oedbtest def test_get_weather_cells_intersecting_with_grid_district(self): weather_cells = tools.get_weather_cells_intersecting_with_grid_district( self.edisgo From 3faa30bb3e4a355824ec7f6030d7f497e420c0a5 Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 11:38:35 +0200 Subject: [PATCH 3/8] Add pytest.mark.oedbtest for failing tests due to oedb error --- tests/network/test_timeseries.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 3818aaf3..8cef16dc 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1550,6 +1550,7 @@ def test_predefined_dispatchable_generators_by_technology(self): ) # fmt: on + @pytest.mark.oedbtest # WARNING: This is NO oedb error, but a demandlib error def test_predefined_conventional_loads_by_sector(self, caplog): index = pd.date_range("1/1/2018", periods=3, freq="H") self.edisgo.timeseries.timeindex = index From 22450da42d78ebfe5d8f3fad96975e32c3932fcb Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 11:54:30 +0200 Subject: [PATCH 4/8] update demandlib dependency to version < 0.2.0 due to demandlib error --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0d83f01f..17e87f85 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def read(fname): requirements = [ "contextily", "dash < 2.9.0", - "demandlib", + "demandlib < 0.2.0", "descartes", "egoio >= 0.4.7", "geoalchemy2 < 0.7.0", From 90dc28b307967561fd4b71b8381b530b78621418 Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 12:03:19 +0200 Subject: [PATCH 5/8] Remove pytest.mark.oedbtest for demandlib error --- tests/network/test_timeseries.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 8cef16dc..3818aaf3 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1550,7 +1550,6 @@ def test_predefined_dispatchable_generators_by_technology(self): ) # fmt: on - @pytest.mark.oedbtest # WARNING: This is NO oedb error, but a demandlib error def test_predefined_conventional_loads_by_sector(self, caplog): index = pd.date_range("1/1/2018", periods=3, freq="H") self.edisgo.timeseries.timeindex = index From 4dcc0eeedcd70cf8e6a391c88d470748ee4ce4ec Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 12:11:44 +0200 Subject: [PATCH 6/8] Revert "update setup.py to newest pypsa and pyomo versions" This reverts commit 7db9daf2012bd35224342cb014337aa18bd87036. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 17e87f85..b77dba80 100644 --- a/setup.py +++ b/setup.py @@ -50,10 +50,10 @@ def read(fname): "plotly", "pydot", "pygeos", - # "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release + "pyomo <= 6.4.2", # Problem with PyPSA 20.1 fixed in newest PyPSA release "pypower", "pyproj >= 3.0.0", - "pypsa", + "pypsa >= 0.17.0, <= 0.20.1", "pyyaml", "saio", "scikit-learn <= 1.1.1", From 7c4cbbbdc8771673cae09f8452adc029271fa0bc Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 17:12:52 +0200 Subject: [PATCH 7/8] Remove pytest.mark.oedbtest for demandlib error --- tests/io/test_timeseries_import.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/io/test_timeseries_import.py b/tests/io/test_timeseries_import.py index 2bae3cf2..17340163 100644 --- a/tests/io/test_timeseries_import.py +++ b/tests/io/test_timeseries_import.py @@ -87,7 +87,6 @@ def test_feedin_oedb(self): assert feedin_df.shape == (6, 4) assert_index_equal(feedin_df.index, timeindex) - @pytest.mark.oedbtest def test_load_time_series_demandlib(self): edisgo = EDisGo(ding0_grid=pytest.ding0_test_network_path) timeindex = pd.date_range("1/1/2018", periods=7000, freq="H") From 47abe91ccadb56e4f04105f150a38a5696fd1e48 Mon Sep 17 00:00:00 2001 From: joda9 Date: Tue, 9 Jul 2024 17:13:38 +0200 Subject: [PATCH 8/8] Skip oedbtest in pytest unless --runoedbtest option is specified --- tests/conftest.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 8dedbc6c..998adaeb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -78,10 +78,8 @@ def pytest_collection_modifyitems(config, items): for item in items: if "runonlinux" in item.keywords: item.add_marker(skip_windows) - if config.getoption("--runoedbtest"): - # If the --runoedbtest option is specified, do not skip any tests - return - skip_oedbtest = pytest.mark.skip(reason="Need --runoedbtest option to run") - for item in items: - if "oedbtest" in item.keywords: - item.add_marker(skip_oedbtest) + if not config.getoption("--runoedbtest"): + skip_oedbtest = pytest.mark.skip(reason="need --runoedbtest option to run") + for item in items: + if "oedbtest" in item.keywords: + item.add_marker(skip_oedbtest)