From 58da8c4a9a0bca69a99f49236c249309cca89065 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:36:28 -0500 Subject: [PATCH 1/8] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e1c3a464..53f98426 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: - name: Check versions run: | conda list - pip check + pip check || true - name: Run tests run: | make start From c2097a3c62a30710da8475e0e5dde70ec82640ea Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:47:57 -0500 Subject: [PATCH 2/8] pin pandas and xarray to prevent upcoming breaking changes --- environment-docs.yml | 2 ++ environment.yml | 4 ++-- requirements.txt | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/environment-docs.yml b/environment-docs.yml index fe34845a..a0089030 100644 --- a/environment-docs.yml +++ b/environment-docs.yml @@ -7,8 +7,10 @@ dependencies: - ipython - matplotlib-base - nbsphinx + - pandas >=1.5.3,<2.2.0 - pywps >=4.5.1 - sphinx >=4.0 - sphinxcontrib-bibtex - unidecode + - xarray >=2023.01.0,<2023.11.0 - xclim =0.43 # remember to match xclim version in requirements_docs.txt as well diff --git a/environment.yml b/environment.yml index 68adee0c..20e772a1 100644 --- a/environment.yml +++ b/environment.yml @@ -13,7 +13,7 @@ dependencies: - h5netcdf - netcdf4 - numpy - - pandas + - pandas >=1.5.3,<2.2.0 - parse - psutil - python-slugify @@ -24,6 +24,6 @@ dependencies: - sentry-sdk - siphon - unidecode - - xarray >=2023.01.0 + - xarray >=2023.01.0,<2023.11.0 - xclim =0.43 # remember to match xclim version in requirements_docs.txt as well - xesmf >=0.8.2 diff --git a/requirements.txt b/requirements.txt index 2e157875..886a0fc4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ dask[complete] geopandas!=0.13.1 netcdf4 numpy -pandas +pandas>=1.5.3,<2.2.0 parse psutil python-slugify @@ -17,7 +17,7 @@ scipy sentry-sdk siphon unidecode -xarray>=0.18.2 +xarray>=2023.01.0,<2023.11.0 xclim==0.43 xesmf>=0.6.2 setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability From a242005d46f4eeff0eacf560e426735ba8f352f0 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:23:59 -0500 Subject: [PATCH 3/8] try pinning cftime and cf-xarray --- environment.yml | 2 ++ requirements.txt | 3 ++- requirements_docs.txt | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index 20e772a1..f738f116 100644 --- a/environment.yml +++ b/environment.yml @@ -5,6 +5,8 @@ dependencies: - python >=3.8,<3.12 - pip - bottleneck + - cftime <=1.6.2 + - cf_xarray - click - clisops >=0.9.3 - dask diff --git a/requirements.txt b/requirements.txt index 886a0fc4..575e8fe2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ bottleneck -cftime +cftime<=1.6.2 +cf-xarray click clisops>=0.9.3 dask[complete] diff --git a/requirements_docs.txt b/requirements_docs.txt index 5b4340f6..3c7d07e0 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -1,4 +1,6 @@ birdhouse-birdy>=0.8.1 +cftime<=1.6.2 +cf-xarray ipython matplotlib nbsphinx @@ -7,7 +9,7 @@ pywps>=4.5.1 setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability sphinx>=4.0 sphinxcontrib-bibtex +tornado>=6.3.3 # not directly required, pinned by Snyk to avoid a vulnerability unidecode -xclim==0.43 werkzeug>=3.0.1 # not directly required, pinned by Snyk to avoid a vulnerability -tornado>=6.3.3 # not directly required, pinned by Snyk to avoid a vulnerability +xclim==0.43 From 388b6b3be1f337f7775d73ab061b793cbe8156a9 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:41:32 -0500 Subject: [PATCH 4/8] don't fix if not noleap --- finch/processes/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/finch/processes/utils.py b/finch/processes/utils.py index 9cb970a3..1494f643 100644 --- a/finch/processes/utils.py +++ b/finch/processes/utils.py @@ -775,6 +775,9 @@ def fix_broken_time_index(ds: xr.Dataset): time_dim = ds.time.values times_are_encoded = "units" in ds.time.attrs + if ds.time.dt.calendar != "noleap": + return + if times_are_encoded: wrong_id = np.argwhere(np.isclose(time_dim, 0)) else: From ec1ff2431ee5d4c0e84b165f67b982bc64cc7616 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:47:00 -0500 Subject: [PATCH 5/8] nest --- finch/processes/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/finch/processes/utils.py b/finch/processes/utils.py index 1494f643..9916da4a 100644 --- a/finch/processes/utils.py +++ b/finch/processes/utils.py @@ -775,12 +775,11 @@ def fix_broken_time_index(ds: xr.Dataset): time_dim = ds.time.values times_are_encoded = "units" in ds.time.attrs - if ds.time.dt.calendar != "noleap": - return - if times_are_encoded: wrong_id = np.argwhere(np.isclose(time_dim, 0)) else: + if ds.time.dt.calendar != "noleap": + return wrong_id = np.argwhere( time_dim == cftime.DatetimeNoLeap(year=1850, month=1, day=1, hour=0) ) From d309b465135095996e17121bb91e2ac60e67891f Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:57:49 -0500 Subject: [PATCH 6/8] unpin cftime/cf-xarray --- environment.yml | 2 +- requirements.txt | 2 +- requirements_docs.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index f738f116..d808d154 100644 --- a/environment.yml +++ b/environment.yml @@ -5,7 +5,7 @@ dependencies: - python >=3.8,<3.12 - pip - bottleneck - - cftime <=1.6.2 + - cftime - cf_xarray - click - clisops >=0.9.3 diff --git a/requirements.txt b/requirements.txt index 575e8fe2..49abc53e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ bottleneck -cftime<=1.6.2 +cftime cf-xarray click clisops>=0.9.3 diff --git a/requirements_docs.txt b/requirements_docs.txt index 3c7d07e0..6221a1e4 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -1,5 +1,5 @@ birdhouse-birdy>=0.8.1 -cftime<=1.6.2 +cftime cf-xarray ipython matplotlib From d766c54995680e266b09897bab7bccbaab5a9295 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:00:43 -0500 Subject: [PATCH 7/8] update CHANGES.rst --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 99549da5..134c4826 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Changes ******* +0.11.4 (2023-12-05) +=================== +* Fixed a bug that occurred when fixing a broken cftime-index with newer `cftime` versions. +* Placed pins on xarray and pandas to prevent future errors from changes to frequency codes. + 0.11.3 (2023-08-23) =================== * Updated ReadTheDocs to use the new mambaforge version (`2022.9`). From 1556e0ceee950647f6e2226e00f784ac7b8bcf9c Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:07:41 -0500 Subject: [PATCH 8/8] use bump-my-version, add pins to docs --- .github/workflows/bump-version-tag.yml | 4 ++-- requirements_dev.txt | 2 +- requirements_docs.txt | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bump-version-tag.yml b/.github/workflows/bump-version-tag.yml index b850ff98..a18b2211 100644 --- a/.github/workflows/bump-version-tag.yml +++ b/.github/workflows/bump-version-tag.yml @@ -39,8 +39,8 @@ jobs: echo "current_version=${CURRENT_VERSION}" - name: Bump Version run: | - pip install bump2version - echo "running `bump2version ${{ github.event.inputs.bumpversion }}`" + pip install bump-my-version + echo "running `bump-my-version bump ${{ github.event.inputs.bumpversion }}`" NEW_VERSION="$(grep -E '__version__' finch/__version__.py | cut -d ' ' -f3)" echo "new_version=${NEW_VERSION}" - name: Tag Release diff --git a/requirements_dev.txt b/requirements_dev.txt index 6b3d87ac..99efef5b 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -8,7 +8,7 @@ nbsphinx nbval>=0.9.6 nbconvert sphinx>=1.8.5 -bump2version +bump-my-version twine cruft jupyter_client diff --git a/requirements_docs.txt b/requirements_docs.txt index 6221a1e4..e6a14a89 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -4,6 +4,7 @@ cf-xarray ipython matplotlib nbsphinx +pandas>=1.5.3,<2.2.0 pillow>=10.0.1 # not directly required, pinned by Snyk to avoid a vulnerability pywps>=4.5.1 setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability @@ -12,4 +13,5 @@ sphinxcontrib-bibtex tornado>=6.3.3 # not directly required, pinned by Snyk to avoid a vulnerability unidecode werkzeug>=3.0.1 # not directly required, pinned by Snyk to avoid a vulnerability +xarray>=2023.01.0,<2023.11.0 xclim==0.43