From 6444a26211e48206189b2fa726aaa51c4c91d1c5 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 7 Mar 2025 08:23:31 -0700 Subject: [PATCH 1/6] Fix import --- .github/workflows/ci.yaml | 4 ++-- .github/workflows/upstream-dev-ci.yaml | 2 +- cf_xarray/__init__.py | 7 ++++++- ci/environment-all-min-deps.yml | 24 ++++++++++++++++++++++++ pyproject.toml | 1 + 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 ci/environment-all-min-deps.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ece0d8df..facb3ed8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: os: ["ubuntu-latest"] - python-version: ["3.10", "3.12"] + python-version: ["3.10", "3.13"] steps: - uses: actions/checkout@v4 with: @@ -91,7 +91,7 @@ jobs: shell: bash -l {0} strategy: matrix: - python-version: ["3.10", "3.12"] + python-version: ["3.10", "3.13"] steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index c5efd597..333305ed 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.12"] + python-version: ["3.13"] steps: - uses: actions/checkout@v4 with: diff --git a/cf_xarray/__init__.py b/cf_xarray/__init__.py index cc038830..6800c2c7 100644 --- a/cf_xarray/__init__.py +++ b/cf_xarray/__init__.py @@ -1,3 +1,7 @@ +import xarray +from packaging.version import Version + +from . import geometry as geometry from . import sgrid # noqa from .accessor import CFAccessor # noqa from .coding import ( # noqa @@ -9,6 +13,7 @@ from .options import set_options # noqa from .utils import _get_version -from . import geometry, groupers # noqa +if Version(xarray.__version__) >= Version("2024.07.0"): + from . import groupers as groupers __version__ = _get_version() diff --git a/ci/environment-all-min-deps.yml b/ci/environment-all-min-deps.yml new file mode 100644 index 00000000..d2ae625c --- /dev/null +++ b/ci/environment-all-min-deps.yml @@ -0,0 +1,24 @@ +name: cf_xarray_test +channels: + - conda-forge +dependencies: + - pytest-cov + - pytest + - pytest-xdist + - dask + - flox + - lxml + - matplotlib-base + - netcdf4 + - pandas + - pint>=0.18,!=0.24.0 + - pooch + - regex + - rich + - pooch + - scipy + - shapely + - xarray>=2022.03.0 + - pip + - pip: + - pytest-pretty diff --git a/pyproject.toml b/pyproject.toml index f167b774..93fd9c13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] dependencies = [ "xarray>=2022.03.0", From 2ae82c2fe0507262e448e04a932ddd4331c58ba8 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 7 Mar 2025 08:31:34 -0700 Subject: [PATCH 2/6] redo CI --- .github/workflows/ci.yaml | 47 +++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index facb3ed8..67020502 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,6 +28,14 @@ jobs: matrix: os: ["ubuntu-latest"] python-version: ["3.10", "3.13"] + env: [""] + include: + - env: "all-min-deps" + python-version: "3.10" + os: ubuntu-latest + - env: "no-optional-deps" + python-version: "3.13" + os: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -35,10 +43,22 @@ jobs: - name: Set environment variables run: | echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV + if [[ "${{ matrix.env }}" == "all-min-deps" ]] ; + then + echo "CONDA_ENV_FILE=ci/environment-all-min-deps.yml" >> $GITHUB_ENV + fi + if [[ "${{ matrix.env }}" == "" ]] ; + then + echo "CONDA_ENV_FILE=ci/environment.yml" >> $GITHUB_ENV + fi + if [[ "${{ matrix.env }}" == "no-optional-deps" ]] ; + then + echo "CONDA_ENV_FILE=ci/environment-no-optional-deps.yml" >> $GITHUB_ENV + fi - name: Set up conda environment uses: mamba-org/setup-micromamba@v2 with: - environment-file: ci/environment.yml + environment-file: ${{ env.CONDA_ENV_FILE }} environment-name: cf_xarray_test cache-environment: true create-args: >- @@ -58,31 +78,6 @@ jobs: name: codecov-umbrella fail_ci_if_error: false - no-optional-deps: - name: no-optional-deps - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v4 - with: - # need to fetch all tags to get a correct version - fetch-depth: 0 # fetch all branches and tags - - name: Set up conda environment - uses: mamba-org/setup-micromamba@v2 - with: - environment-file: ci/environment-no-optional-deps.yml - environment-name: cf_xarray_test - cache-environment: true - - name: Install cf_xarray - run: | - python -m pip install --no-deps -e . - - name: Run Tests - shell: bash -l {0} - run: | - pytest -n 2 - mypy: name: mypy runs-on: "ubuntu-latest" From bb27aca2bad2a235614e1eecfbbed24019585188 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 7 Mar 2025 08:33:42 -0700 Subject: [PATCH 3/6] fix name --- .github/workflows/ci.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 67020502..d7e090b0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ env: jobs: build: - name: Build (${{ matrix.python-version }}, ${{ matrix.os }}) + name: Build (${{ matrix.python-version }}, ${{ matrix.os }}), ${{ matrix.env }} runs-on: ${{ matrix.os }} defaults: run: @@ -43,10 +43,6 @@ jobs: - name: Set environment variables run: | echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV - if [[ "${{ matrix.env }}" == "all-min-deps" ]] ; - then - echo "CONDA_ENV_FILE=ci/environment-all-min-deps.yml" >> $GITHUB_ENV - fi if [[ "${{ matrix.env }}" == "" ]] ; then echo "CONDA_ENV_FILE=ci/environment.yml" >> $GITHUB_ENV @@ -55,6 +51,10 @@ jobs: then echo "CONDA_ENV_FILE=ci/environment-no-optional-deps.yml" >> $GITHUB_ENV fi + if [[ "${{ matrix.env }}" == "all-min-deps" ]] ; + then + echo "CONDA_ENV_FILE=ci/environment-all-min-deps.yml" >> $GITHUB_ENV + fi - name: Set up conda environment uses: mamba-org/setup-micromamba@v2 with: From 1072ec0f286b14381b82daf0b64facf1f9c38f6b Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 7 Mar 2025 08:35:35 -0700 Subject: [PATCH 4/6] fix min deps --- ci/environment-all-min-deps.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/environment-all-min-deps.yml b/ci/environment-all-min-deps.yml index d2ae625c..b30067cd 100644 --- a/ci/environment-all-min-deps.yml +++ b/ci/environment-all-min-deps.yml @@ -11,14 +11,14 @@ dependencies: - matplotlib-base - netcdf4 - pandas - - pint>=0.18,!=0.24.0 + - pint==0.19 - pooch - regex - rich - pooch - scipy - shapely - - xarray>=2022.03.0 + - xarray==2022.03.0 - pip - pip: - pytest-pretty From 549edcb6dddca0fb902ebdf4fed76a93a4ee71b3 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 7 Mar 2025 08:40:08 -0700 Subject: [PATCH 5/6] bump min xarray --- ci/environment-all-min-deps.yml | 2 +- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/environment-all-min-deps.yml b/ci/environment-all-min-deps.yml index b30067cd..8b431eb7 100644 --- a/ci/environment-all-min-deps.yml +++ b/ci/environment-all-min-deps.yml @@ -18,7 +18,7 @@ dependencies: - pooch - scipy - shapely - - xarray==2022.03.0 + - xarray==2023.09.0 - pip - pip: - pytest-pretty diff --git a/pyproject.toml b/pyproject.toml index 93fd9c13..2269b133 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ classifiers = [ "Programming Language :: Python :: 3.13", ] dependencies = [ - "xarray>=2022.03.0", + "xarray>=2023.09.0", ] dynamic = ["version"] @@ -33,7 +33,7 @@ changelog = "https://cf-xarray.readthedocs.io/en/latest/whats-new.html" [build-system] requires = [ # xarray is need for dynamic version string - "xarray>=2022.03.0", + "xarray>=2023.09.0", "setuptools>=45", "setuptools_scm[toml]>=6.2", ] From cf8b83860107a6ffa3d0dd650b070f7ec432bec8 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 7 Mar 2025 08:48:17 -0700 Subject: [PATCH 6/6] importorskip --- cf_xarray/tests/test_groupers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cf_xarray/tests/test_groupers.py b/cf_xarray/tests/test_groupers.py index 8c87d695..489d0cf8 100644 --- a/cf_xarray/tests/test_groupers.py +++ b/cf_xarray/tests/test_groupers.py @@ -3,6 +3,8 @@ import xarray as xr from xarray.testing import assert_identical +pytest.importorskip("xarray", "2024.07.0") + from cf_xarray.datasets import flag_excl from cf_xarray.groupers import FlagGrouper