From 922aa4e03f3b45ed14a093bdb8ff0cd0ce09b9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Sun, 18 Jun 2023 18:06:46 +0300 Subject: [PATCH 01/15] Couple of tests for fore --- .../src/tests/apis/forecast_test.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 recommender-back/src/tests/apis/forecast_test.py diff --git a/recommender-back/src/tests/apis/forecast_test.py b/recommender-back/src/tests/apis/forecast_test.py new file mode 100644 index 00000000..9c6706ba --- /dev/null +++ b/recommender-back/src/tests/apis/forecast_test.py @@ -0,0 +1,42 @@ +import unittest +import numpy as np +from unittest.mock import patch +from apis.weather import ForecastGrid, parse_forecast +from fmiopendata import grid + +class ForecastTest(unittest.TestCase): + def setUp(self): + self.forecastgrid = ForecastGrid() + + self.mock_coords = np.array([ + [[60.1, 24.6]], + [[60.2, 24.7]], + [[60.3, 24.8]], + [[60.4, 24.9]], + [[60.5, 25.0]], + ]) + + self.forecastgrid.coordinates = self.mock_coords + + def test_forecast_data_is_parsed_correctly(self): + forecast_data = [{'Dataset': '2 metre temperature', 'Unit': 'K', 'Data': 280.0}, + {'Dataset': '2 metre relative humidity', 'Unit': '%', 'Data': 64.013}, + {'Dataset': '10 metre wind speed', 'Unit': 'm s**-1', 'Data': 1.6543}, + {'Dataset': 'Mean sea level pressure', 'Unit': 'Pa', 'Data': 101500.2423}] + + expected_data = {'Air temperature': '6.9 °C', + 'Wind': '1.7 m/s', + 'Air pressure': '1015.0 mbar', + 'Humidity': '64.0 %'} + + parsed_data = parse_forecast(forecast_data) + + self.assertEqual(parsed_data, expected_data) + + def test_get_coordinates_returns_correct_pairs(self): + self.latitudes = self.mock_coords[:, 0, 0].flatten() + self.longitudes = self.mock_coords[:, 0, 1].flatten() + + coordinates = self.forecastgrid.get_coordinates() + for lat, lon in zip(self.latitudes, self.longitudes): + assert any(np.allclose([lat, lon], coord) for coord in coordinates) From 996d2aef4f3cab14a0a06035aab71a9efd3f89e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 07:44:56 +0300 Subject: [PATCH 02/15] Test update data --- .../src/tests/apis/forecast_test.py | 95 ++++++++++++++----- 1 file changed, 69 insertions(+), 26 deletions(-) diff --git a/recommender-back/src/tests/apis/forecast_test.py b/recommender-back/src/tests/apis/forecast_test.py index 9c6706ba..b7853993 100644 --- a/recommender-back/src/tests/apis/forecast_test.py +++ b/recommender-back/src/tests/apis/forecast_test.py @@ -1,42 +1,85 @@ import unittest import numpy as np -from unittest.mock import patch -from apis.weather import ForecastGrid, parse_forecast +from datetime import datetime, timedelta from fmiopendata import grid +from unittest.mock import MagicMock, PropertyMock, patch +from apis.weather import ForecastGrid, parse_forecast class ForecastTest(unittest.TestCase): def setUp(self): + self.datetime_mock = MagicMock() + self.mock_grid = MagicMock(spec=grid.Grid) self.forecastgrid = ForecastGrid() - self.mock_coords = np.array([ - [[60.1, 24.6]], - [[60.2, 24.7]], - [[60.3, 24.8]], - [[60.4, 24.9]], - [[60.5, 25.0]], - ]) + mock_grid_data = { + 0: { + 'Mean sea level pressure': { + 'units': 'Pa', + 'data': np.array([[1000, 1000, 1000, 1000, 1000]]) + }, + }, + 2: { + '2 metre temperature': { + 'units': 'K', + 'data': np.array([[280, 280, 280, 280, 280]]) + } + }, + 10: { + 'Mean wind direction': { + 'units': 'degrees', + 'data': np.array([[180, 180, 180, 180, 180]]) + } + } + } - self.forecastgrid.coordinates = self.mock_coords + mock_datetimes = { + datetime.now(): self.mock_grid, + datetime.now() - timedelta(hours=3): self.mock_grid, + datetime.now() - timedelta(hours=6): self.mock_grid + } - def test_forecast_data_is_parsed_correctly(self): - forecast_data = [{'Dataset': '2 metre temperature', 'Unit': 'K', 'Data': 280.0}, - {'Dataset': '2 metre relative humidity', 'Unit': '%', 'Data': 64.013}, - {'Dataset': '10 metre wind speed', 'Unit': 'm s**-1', 'Data': 1.6543}, - {'Dataset': 'Mean sea level pressure', 'Unit': 'Pa', 'Data': 101500.2423}] + self.datetime_mock.data = mock_datetimes + type(self.mock_grid).latitudes = PropertyMock(return_value=np.array([[60.1, 60.2, 60.3, 60.4, 60.5]])) + type(self.mock_grid).longitudes = PropertyMock(return_value=np.array([[24.6, 24.7, 24.8, 24.9, 25.0]])) + type(self.mock_grid).data = PropertyMock(return_value=mock_grid_data) - expected_data = {'Air temperature': '6.9 °C', - 'Wind': '1.7 m/s', - 'Air pressure': '1015.0 mbar', - 'Humidity': '64.0 %'} - - parsed_data = parse_forecast(forecast_data) + @patch('apis.weather.download_stored_query') + def test_data_is_updated_correctly(self, mock_download_stored_query): + mock_download_stored_query.return_value = self.datetime_mock - self.assertEqual(parsed_data, expected_data) + self.forecastgrid.update_data() - def test_get_coordinates_returns_correct_pairs(self): - self.latitudes = self.mock_coords[:, 0, 0].flatten() - self.longitudes = self.mock_coords[:, 0, 1].flatten() + #check that data contains a grid object + self.assertEqual(self.forecastgrid.data, self.mock_grid) + + #check coordinates + np.testing.assert_array_equal( + self.forecastgrid.coordinates, + np.array([((60.1, 24.6), (60.2, 24.7), (60.3, 24.8), (60.4, 24.9), (60.5, 25.0))])) + + #check valid_times + self.assertEqual(self.forecastgrid.valid_times, self.mock_grid.data.keys()) + + #check data levels + self.assertEqual(self.forecastgrid.data_levels, [0, 2, 10]) + def test_get_coordinates_returns_correct_pairs(self): + self.forecastgrid.coordinates = np.dstack((self.mock_grid.latitudes, self.mock_grid.longitudes)) coordinates = self.forecastgrid.get_coordinates() - for lat, lon in zip(self.latitudes, self.longitudes): + for lat, lon in zip(self.mock_grid.latitudes.flatten(), self.mock_grid.longitudes.flatten()): assert any(np.allclose([lat, lon], coord) for coord in coordinates) + + def test_forecast_data_is_parsed_correctly(self): + datasets = [{'Dataset': '2 metre temperature', 'Unit': 'K', 'Data': 280.0}, + {'Dataset': '2 metre relative humidity', 'Unit': '%', 'Data': 64.013}, + {'Dataset': '10 metre wind speed', 'Unit': 'm s**-1', 'Data': 1.6543}, + {'Dataset': 'Mean sea level pressure', 'Unit': 'Pa', 'Data': 101500.2423}] + + expected_parsed_data = {'Air temperature': '6.9 °C', + 'Wind': '1.7 m/s', + 'Air pressure': '1015.0 mbar', + 'Humidity': '64.0 %'} + + parsed_data = parse_forecast(datasets) + + self.assertEqual(parsed_data, expected_parsed_data) From 8e4c58e26c3cd7166d793d59a494a5be518880c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 09:20:00 +0300 Subject: [PATCH 03/15] Fix forecast tests --- .../src/tests/apis/forecast_test.py | 93 ++++++++++--------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/recommender-back/src/tests/apis/forecast_test.py b/recommender-back/src/tests/apis/forecast_test.py index b7853993..5e7ea52b 100644 --- a/recommender-back/src/tests/apis/forecast_test.py +++ b/recommender-back/src/tests/apis/forecast_test.py @@ -1,85 +1,90 @@ import unittest import numpy as np -from datetime import datetime, timedelta +from datetime import datetime from fmiopendata import grid from unittest.mock import MagicMock, PropertyMock, patch from apis.weather import ForecastGrid, parse_forecast class ForecastTest(unittest.TestCase): def setUp(self): - self.datetime_mock = MagicMock() - self.mock_grid = MagicMock(spec=grid.Grid) self.forecastgrid = ForecastGrid() + self.grid_by_datetime = MagicMock() + self.mock_grid = MagicMock(spec=grid.Grid) - mock_grid_data = { - 0: { - 'Mean sea level pressure': { - 'units': 'Pa', - 'data': np.array([[1000, 1000, 1000, 1000, 1000]]) + self.grid_by_datetime.data = { + datetime(2023, 6, 19, 5, 0): self.mock_grid + } + + self.mock_grid_data = PropertyMock(return_value={ + datetime(2023, 6, 19, 5, 0): { + 0: { + 'Mean sea level pressure': { + 'units': 'Pa', + 'data': np.array([[10300, 10500, 10600, 10700, 10800]]) + } }, - }, - 2: { - '2 metre temperature': { - 'units': 'K', - 'data': np.array([[280, 280, 280, 280, 280]]) - } - }, - 10: { - 'Mean wind direction': { - 'units': 'degrees', - 'data': np.array([[180, 180, 180, 180, 180]]) + 2: { + '2 metre temperature': { + 'units': 'K', + 'data': np.array([[288.2, 287.3, 283.5, 291.4, 287.7]]) + } + }, + 10: { + '10 metre wind speed': { + 'units': 'm s**-1', + 'data': np.array([[1.23, 1.7, 1.43, 1.42, 1.77]]) + } } } - } - - mock_datetimes = { - datetime.now(): self.mock_grid, - datetime.now() - timedelta(hours=3): self.mock_grid, - datetime.now() - timedelta(hours=6): self.mock_grid - } + }) - self.datetime_mock.data = mock_datetimes + type(self.mock_grid).data = self.mock_grid_data type(self.mock_grid).latitudes = PropertyMock(return_value=np.array([[60.1, 60.2, 60.3, 60.4, 60.5]])) type(self.mock_grid).longitudes = PropertyMock(return_value=np.array([[24.6, 24.7, 24.8, 24.9, 25.0]])) - type(self.mock_grid).data = PropertyMock(return_value=mock_grid_data) @patch('apis.weather.download_stored_query') def test_data_is_updated_correctly(self, mock_download_stored_query): - mock_download_stored_query.return_value = self.datetime_mock + mock_download_stored_query.return_value = self.grid_by_datetime self.forecastgrid.update_data() - #check that data contains a grid object - self.assertEqual(self.forecastgrid.data, self.mock_grid) + # Check that data contains a grid object + self.assertIsInstance(self.forecastgrid.data, type(self.mock_grid)) - #check coordinates + # Check that coordinates are now pairs np.testing.assert_array_equal( - self.forecastgrid.coordinates, - np.array([((60.1, 24.6), (60.2, 24.7), (60.3, 24.8), (60.4, 24.9), (60.5, 25.0))])) + self.forecastgrid.coordinates, + np.array([((60.1, 24.6), (60.2, 24.7), (60.3, 24.8), (60.4, 24.9), (60.5, 25.0))]) + ) - #check valid_times - self.assertEqual(self.forecastgrid.valid_times, self.mock_grid.data.keys()) + # Check that valid_times returns datetime dict_keys + expected_valid_times = self.grid_by_datetime.data.keys() + self.assertEqual(self.forecastgrid.valid_times, expected_valid_times) - #check data levels - self.assertEqual(self.forecastgrid.data_levels, [0, 2, 10]) + # Check that all data levels match + expected_data_levels = [] + for datetime_data in self.mock_grid.data.values(): + data_levels = datetime_data.keys() + expected_data_levels.extend(data_levels) + self.assertListEqual(list(self.forecastgrid.data_levels), expected_data_levels) - def test_get_coordinates_returns_correct_pairs(self): + def test_get_coordinates_returns_correct_list_of_pairs(self): self.forecastgrid.coordinates = np.dstack((self.mock_grid.latitudes, self.mock_grid.longitudes)) coordinates = self.forecastgrid.get_coordinates() for lat, lon in zip(self.mock_grid.latitudes.flatten(), self.mock_grid.longitudes.flatten()): assert any(np.allclose([lat, lon], coord) for coord in coordinates) def test_forecast_data_is_parsed_correctly(self): - datasets = [{'Dataset': '2 metre temperature', 'Unit': 'K', 'Data': 280.0}, - {'Dataset': '2 metre relative humidity', 'Unit': '%', 'Data': 64.013}, - {'Dataset': '10 metre wind speed', 'Unit': 'm s**-1', 'Data': 1.6543}, - {'Dataset': 'Mean sea level pressure', 'Unit': 'Pa', 'Data': 101500.2423}] + data = [{'Dataset': '2 metre temperature', 'Unit': 'K', 'Data': 280.0}, + {'Dataset': '2 metre relative humidity', 'Unit': '%', 'Data': 64.013}, + {'Dataset': '10 metre wind speed', 'Unit': 'm s**-1', 'Data': 1.6543}, + {'Dataset': 'Mean sea level pressure', 'Unit': 'Pa', 'Data': 101500.2423}] expected_parsed_data = {'Air temperature': '6.9 °C', 'Wind': '1.7 m/s', 'Air pressure': '1015.0 mbar', 'Humidity': '64.0 %'} - parsed_data = parse_forecast(datasets) + parsed_data = parse_forecast(data) self.assertEqual(parsed_data, expected_parsed_data) From 6532b7c69fd44a69bfeef1e17d018876e8882d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 12:40:49 +0300 Subject: [PATCH 04/15] Eccodes install to ci --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a78eef02..338568e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,10 @@ jobs: run: | cd recommender-back pip install poetry + - name: Install Eccodes + run: | + cd recommender-back + pip install eccodes - name: Install dependencies run: | cd recommender-back From d2a3ea3e97961634103f0e028674d6076d0a259d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 12:44:53 +0300 Subject: [PATCH 05/15] Add conda install eccodes --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 338568e1..abd7cded 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,7 @@ jobs: - name: Install Eccodes run: | cd recommender-back + conda install eccodes -c conda-forge pip install eccodes - name: Install dependencies run: | From 44e9fea1ad9f2422503199a457f8a0652dab0134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 12:55:16 +0300 Subject: [PATCH 06/15] Install everything --- .github/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abd7cded..986755a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,11 +20,18 @@ jobs: run: | cd recommender-back pip install poetry + - name: Install Ecmwflibs + run: | + cd recommender-back + pip install ecmwflibs - name: Install Eccodes run: | cd recommender-back - conda install eccodes -c conda-forge - pip install eccodes + pip install eccodes==1.3.1 + - name: Install Cfgirbs + run: | + cd recommender-back + pip install cfgrib - name: Install dependencies run: | cd recommender-back From c88b359187a5ff47366b1fb6eeb64566426b76e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 13:01:10 +0300 Subject: [PATCH 07/15] Change import style --- recommender-back/src/tests/apis/forecast_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recommender-back/src/tests/apis/forecast_test.py b/recommender-back/src/tests/apis/forecast_test.py index 5e7ea52b..c31c11ed 100644 --- a/recommender-back/src/tests/apis/forecast_test.py +++ b/recommender-back/src/tests/apis/forecast_test.py @@ -1,7 +1,8 @@ import unittest import numpy as np +import eccodes from datetime import datetime -from fmiopendata import grid +from fmiopendata.grid import Grid from unittest.mock import MagicMock, PropertyMock, patch from apis.weather import ForecastGrid, parse_forecast @@ -9,7 +10,7 @@ class ForecastTest(unittest.TestCase): def setUp(self): self.forecastgrid = ForecastGrid() self.grid_by_datetime = MagicMock() - self.mock_grid = MagicMock(spec=grid.Grid) + self.mock_grid = MagicMock(spec=Grid) self.grid_by_datetime.data = { datetime(2023, 6, 19, 5, 0): self.mock_grid From df09b8e6aaf19068cbc7c18299940e5efda72cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 13:04:26 +0300 Subject: [PATCH 08/15] Change eccodes version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 986755a1..78610d49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Install Eccodes run: | cd recommender-back - pip install eccodes==1.3.1 + pip install eccodes==1.2.0 - name: Install Cfgirbs run: | cd recommender-back From e3a113a01d9078a08cc057f1bae6de02f44971d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 13:16:58 +0300 Subject: [PATCH 09/15] Change eccodes version again --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78610d49..aa277b3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Install Eccodes run: | cd recommender-back - pip install eccodes==1.2.0 + pip install eccodes==1.5.2 - name: Install Cfgirbs run: | cd recommender-back From bbf262797cbb86c75e9fb8ef999908191ddfc796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 13:22:37 +0300 Subject: [PATCH 10/15] Install pygrib --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa277b3e..df0025c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,10 @@ jobs: run: | cd recommender-back pip install poetry + - name: Install Pygrib + run: | + cd recommender-back + pip install pygrib - name: Install Ecmwflibs run: | cd recommender-back From 1140f287355736a95465cf634804c408284986fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 13:26:49 +0300 Subject: [PATCH 11/15] Add conda again --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df0025c5..783a6d68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: - name: Install Eccodes run: | cd recommender-back + conda install eccodes -c conda-forge pip install eccodes==1.5.2 - name: Install Cfgirbs run: | From 562cfc2fb96da8da2f429b6758fd43fa9a1acd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 13:49:11 +0300 Subject: [PATCH 12/15] Eccodes-python --- .github/workflows/ci.yml | 4 ++++ recommender-back/pyproject.toml | 1 + 2 files changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 783a6d68..442e9049 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,10 @@ jobs: run: | cd recommender-back pip install ecmwflibs + - name: Install Eccodes-Python + run: | + cd recommender-back + pip install eccodes-python - name: Install Eccodes run: | cd recommender-back diff --git a/recommender-back/pyproject.toml b/recommender-back/pyproject.toml index 8ffa976d..1cc440f2 100644 --- a/recommender-back/pyproject.toml +++ b/recommender-back/pyproject.toml @@ -19,6 +19,7 @@ e = "^1.4.5" eccodes = "^1.5.2" python-dotenv = "^1.0.0" requests = "^2.31.0" +eccodes-python = "^0.9.9" [tool.poetry.group.dev.dependencies] From cbcea11e8657dfb8868d2738374b9d28dc36a6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 16:14:57 +0300 Subject: [PATCH 13/15] Try without mocking spec=Grid --- recommender-back/src/tests/apis/forecast_test.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/recommender-back/src/tests/apis/forecast_test.py b/recommender-back/src/tests/apis/forecast_test.py index c31c11ed..6004b881 100644 --- a/recommender-back/src/tests/apis/forecast_test.py +++ b/recommender-back/src/tests/apis/forecast_test.py @@ -1,8 +1,6 @@ import unittest import numpy as np -import eccodes from datetime import datetime -from fmiopendata.grid import Grid from unittest.mock import MagicMock, PropertyMock, patch from apis.weather import ForecastGrid, parse_forecast @@ -10,7 +8,7 @@ class ForecastTest(unittest.TestCase): def setUp(self): self.forecastgrid = ForecastGrid() self.grid_by_datetime = MagicMock() - self.mock_grid = MagicMock(spec=Grid) + self.mock_grid = MagicMock() self.grid_by_datetime.data = { datetime(2023, 6, 19, 5, 0): self.mock_grid From 5e65a833cb4bd3aafb5adba915d61bf0e4801b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 16:35:21 +0300 Subject: [PATCH 14/15] Fix tests and revert ci.yml changes --- .github/workflows/ci.yml | 21 ------------------- .../src/tests/apis/forecast_test.py | 14 ++++++++----- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 442e9049..a78eef02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,27 +20,6 @@ jobs: run: | cd recommender-back pip install poetry - - name: Install Pygrib - run: | - cd recommender-back - pip install pygrib - - name: Install Ecmwflibs - run: | - cd recommender-back - pip install ecmwflibs - - name: Install Eccodes-Python - run: | - cd recommender-back - pip install eccodes-python - - name: Install Eccodes - run: | - cd recommender-back - conda install eccodes -c conda-forge - pip install eccodes==1.5.2 - - name: Install Cfgirbs - run: | - cd recommender-back - pip install cfgrib - name: Install dependencies run: | cd recommender-back diff --git a/recommender-back/src/tests/apis/forecast_test.py b/recommender-back/src/tests/apis/forecast_test.py index 6004b881..4bd08357 100644 --- a/recommender-back/src/tests/apis/forecast_test.py +++ b/recommender-back/src/tests/apis/forecast_test.py @@ -76,13 +76,17 @@ def test_get_coordinates_returns_correct_list_of_pairs(self): def test_forecast_data_is_parsed_correctly(self): data = [{'Dataset': '2 metre temperature', 'Unit': 'K', 'Data': 280.0}, {'Dataset': '2 metre relative humidity', 'Unit': '%', 'Data': 64.013}, - {'Dataset': '10 metre wind speed', 'Unit': 'm s**-1', 'Data': 1.6543}, - {'Dataset': 'Mean sea level pressure', 'Unit': 'Pa', 'Data': 101500.2423}] + {'Dataset': '10 metre U wind component', 'Unit': 'm s**-1', 'Data': 1.223}, + {'Dataset': '10 metre V wind component', 'Unit': 'm s**-1', 'Data': -4.7}, + {'Dataset': 'surface precipitation amount, rain, convective', 'Unit': 'kg m**-2', 'Data': 0.0231}, + {'Dataset': 'Total Cloud Cover', 'Unit': '%', 'Data': 23.2}] expected_parsed_data = {'Air temperature': '6.9 °C', - 'Wind': '1.7 m/s', - 'Air pressure': '1015.0 mbar', - 'Humidity': '64.0 %'} + 'Humidity': '64.0 %', + 'WindU': '1.2', + 'WindV': '-4.7', + 'Precipication': '0.0', + 'Total Cloud Cover': '23.2'} parsed_data = parse_forecast(data) From 19e795217f4247168bc82c4c9c213d14f76b2312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4nnist=C3=B6?= Date: Mon, 19 Jun 2023 16:41:08 +0300 Subject: [PATCH 15/15] Removed eccodes-python dependency --- recommender-back/pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/recommender-back/pyproject.toml b/recommender-back/pyproject.toml index 1cc440f2..8ffa976d 100644 --- a/recommender-back/pyproject.toml +++ b/recommender-back/pyproject.toml @@ -19,7 +19,6 @@ e = "^1.4.5" eccodes = "^1.5.2" python-dotenv = "^1.0.0" requests = "^2.31.0" -eccodes-python = "^0.9.9" [tool.poetry.group.dev.dependencies]