From 17ef03757a646edf3c69889535900a34267c28ff Mon Sep 17 00:00:00 2001 From: SimonKamuk Date: Fri, 25 Apr 2025 13:36:40 +0000 Subject: [PATCH 1/6] use correct python version in tests --- .github/workflows/python-package-pip.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/python-package-pip.yml b/.github/workflows/python-package-pip.yml index 14f46d3..bc9aeaa 100644 --- a/.github/workflows/python-package-pip.yml +++ b/.github/workflows/python-package-pip.yml @@ -21,6 +21,12 @@ jobs: zarr-version: [">=2,<3", ">2,<=3"] steps: - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install package with pip run: | python -m pip install . "zarr${{ matrix.zarr-version }}" From b40a43041e5e3887a8bf7c644d2053a13b7848a7 Mon Sep 17 00:00:00 2001 From: SimonKamuk Date: Fri, 25 Apr 2025 13:38:55 +0000 Subject: [PATCH 2/6] fix type annotation with old notation for union --- mllam_data_prep/create_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mllam_data_prep/create_dataset.py b/mllam_data_prep/create_dataset.py index 1718322..7a1f2d4 100644 --- a/mllam_data_prep/create_dataset.py +++ b/mllam_data_prep/create_dataset.py @@ -2,7 +2,7 @@ import shutil from collections import defaultdict from pathlib import Path -from typing import Optional +from typing import Optional, Union import numpy as np import xarray as xr @@ -294,7 +294,7 @@ def create_dataset(config: Config): return ds -def create_dataset_zarr(fp_config: Path, fp_zarr: Optional[str | Path] = None): +def create_dataset_zarr(fp_config: Path, fp_zarr: Optional[Union[str, Path]] = None): """ Create a dataset from the input datasets specified in the config file and write it to a zarr file. The path to the zarr file is the same as the config file, but with the extension changed to '.zarr'. From 37f84f9218e0abe277da2f549eb1e57f5f188c7d Mon Sep 17 00:00:00 2001 From: SimonKamuk Date: Fri, 25 Apr 2025 13:46:55 +0000 Subject: [PATCH 3/6] use new pre-commit version --- .github/workflows/ci-pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pre-commit.yml b/.github/workflows/ci-pre-commit.yml index 542bd8b..2372819 100644 --- a/.github/workflows/ci-pre-commit.yml +++ b/.github/workflows/ci-pre-commit.yml @@ -18,4 +18,4 @@ jobs: # don't use python3.12 because flake8 finds extra issues with that # version python-version: "3.11" - - uses: pre-commit/action@v2.0.3 + - uses: pre-commit/action@v3.0.1 From 33e0c378c45a3ea44516d355477b5f75ecfb7583 Mon Sep 17 00:00:00 2001 From: SimonKamuk Date: Fri, 25 Apr 2025 13:52:52 +0000 Subject: [PATCH 4/6] update changelog --- CHANGELOG.md | 9 +++++++++ mllam_data_prep/create_dataset.py | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 054378b..80285d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [unreleased](https://github.com/mllam/mllam-data-prep/compare/v0.6.0...HEAD) + +### Fixes +- use old union typing notation compatible with all required python versions [\#77](https://github.com/mllam/mllam-data-prep/pull/77) @SimonKamuk + +### Maintenance +- update pre-commit action to v3.0.1 [\#77](https://github.com/mllam/mllam-data-prep/pull/77) @SimonKamuk +- fix tests to use expected python version from test matrix [\#77](https://github.com/mllam/mllam-data-prep/pull/77) @SimonKamuk + ## [v0.6.0](https://github.com/mllam/mllam-data-prep/release/tag/v0.6.0) [All changes](https://github.com/mllam/mllam-data-prep/compare/v0.6.0...v0.5.0) diff --git a/mllam_data_prep/create_dataset.py b/mllam_data_prep/create_dataset.py index e6eaed2..3daf321 100644 --- a/mllam_data_prep/create_dataset.py +++ b/mllam_data_prep/create_dataset.py @@ -302,7 +302,9 @@ def create_dataset(config: Config): def create_dataset_zarr( - fp_config: Path, fp_zarr: Optional[Union[str, Path]] = None, overwrite: str = "always" + fp_config: Path, + fp_zarr: Optional[Union[str, Path]] = None, + overwrite: str = "always", ): """ Create a dataset from the input datasets specified in the config file and From 69e114c0f05fa48d7939d9b078755f3bc9dd813e Mon Sep 17 00:00:00 2001 From: SimonKamuk Date: Fri, 25 Apr 2025 14:04:53 +0000 Subject: [PATCH 5/6] use old Union typing operator in tests --- tests/derive_variable/conftest.py | 6 ++++-- tests/derive_variable/test_physical_field.py | 12 ++++++------ tests/derive_variable/test_time_components.py | 5 +++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/derive_variable/conftest.py b/tests/derive_variable/conftest.py index 913d0cc..a81a3c3 100644 --- a/tests/derive_variable/conftest.py +++ b/tests/derive_variable/conftest.py @@ -1,7 +1,7 @@ """Fixtures for the derive_variable module tests.""" import datetime -from typing import List +from typing import List, Union import isodate import numpy as np @@ -11,7 +11,9 @@ @pytest.fixture(name="time") -def fixture_time(request) -> List[np.datetime64 | datetime.datetime | xr.DataArray]: +def fixture_time( + request, +) -> List[Union[np.datetime64, datetime.datetime, xr.DataArray]]: """Fixture that returns test time data The fixture has to be indirectly parametrized with the number of time steps. diff --git a/tests/derive_variable/test_physical_field.py b/tests/derive_variable/test_physical_field.py index a3ee7b5..9258d65 100644 --- a/tests/derive_variable/test_physical_field.py +++ b/tests/derive_variable/test_physical_field.py @@ -1,7 +1,7 @@ """Unit tests for the `mllam_data_prep.ops.derive_variable.physical_field` module.""" import datetime -from typing import List +from typing import List, Union import numpy as np import pytest @@ -11,7 +11,7 @@ @pytest.fixture(name="lat") -def fixture_lat(request) -> List[float | xr.DataArray]: +def fixture_lat(request) -> List[Union[float, xr.DataArray]]: """Fixture that returns test latitude data The fixture has to be indirectly parametrized with the number of coordinates, @@ -30,7 +30,7 @@ def fixture_lat(request) -> List[float | xr.DataArray]: @pytest.fixture(name="lon") -def fixture_lon(request) -> List[float | xr.DataArray]: +def fixture_lon(request) -> List[Union[float, xr.DataArray]]: """Fixture that returns test longitude data The fixture has to be indirectly parametrized with the number of coordinates, @@ -62,9 +62,9 @@ def fixture_lon(request) -> List[float | xr.DataArray]: ) @pytest.mark.parametrize("time", [1, 10, 100], indirect=True) def test_toa_radiation( - lat: float | xr.DataArray, - lon: float | xr.DataArray, - time: np.datetime64 | datetime.datetime | xr.DataArray, + lat: Union[float, xr.DataArray], + lon: Union[float, xr.DataArray], + time: Union[np.datetime64, datetime.datetime, xr.DataArray], ): """Test the `calculate_toa_radiation` function. diff --git a/tests/derive_variable/test_time_components.py b/tests/derive_variable/test_time_components.py index 69c8d54..8a5e216 100644 --- a/tests/derive_variable/test_time_components.py +++ b/tests/derive_variable/test_time_components.py @@ -1,6 +1,7 @@ """Unit tests for the `mllam_data_prep.ops.derive_variable.time_components` module.""" import datetime +from typing import Union import numpy as np import pytest @@ -21,7 +22,7 @@ ], ) def test_hour_of_day( - time: np.datetime64 | datetime.datetime | xr.DataArray, component: str + time: Union[np.datetime64, datetime.datetime, xr.DataArray], component: str ): """Test the `calculate_hour_of_day` function. @@ -43,7 +44,7 @@ def test_hour_of_day( ], ) def test_day_of_year( - time: np.datetime64 | datetime.datetime | xr.DataArray, component: str + time: Union[np.datetime64, datetime.datetime, xr.DataArray], component: str ): """Test the `calculate_day_of_year` function. From 3dccd75c8537ddfba8c51d4a2ba6adfcd22a2cb5 Mon Sep 17 00:00:00 2001 From: SimonKamuk Date: Tue, 29 Apr 2025 07:02:38 +0000 Subject: [PATCH 6/6] remove tests for python 3.8 --- .github/workflows/python-package-pip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package-pip.yml b/.github/workflows/python-package-pip.yml index 8e5d79f..6611adb 100644 --- a/.github/workflows/python-package-pip.yml +++ b/.github/workflows/python-package-pip.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10"] zarr-version: [">=2,<3", ">2,<=3"] steps: - uses: actions/checkout@v2