From 3bb138730bfe56135c1dc26b51b6f2863561a133 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:18:16 -0500 Subject: [PATCH 01/22] bump deps Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> --- environment-docs.yml | 10 +++++----- pyproject.toml | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/environment-docs.yml b/environment-docs.yml index 4e2f7827..eea225a9 100644 --- a/environment-docs.yml +++ b/environment-docs.yml @@ -5,11 +5,11 @@ dependencies: - python >=3.13,<3.14 - raven-hydro >=0.5.0,<1.0 - autodoc-pydantic >=2.1.0 - - birdy + - birdy >=0.9.1 - cairosvg >=2.6.0 - cartopy >=0.23.0 - click >=8.2.0 - - clisops >=0.15.0 + - clisops >=0.16.1 - gcsfs - gdal >=3.1 - h5netcdf >=1.5.0 @@ -21,11 +21,11 @@ dependencies: - intake-xarray <2.0 - ipykernel - ipyleaflet - - ipython >=8.5.0 + - ipython >=8.7.0 - jupyter-cache - jupyter_client - jupytext - - matplotlib-base >=3.6.0 + - matplotlib-base >=3.7.0 - myst-nb - nbsphinx >=0.9.5 - netCDF4 >=1.7.2 @@ -33,7 +33,7 @@ dependencies: - notebook - pandas >=2.2 - pydantic >=2.11 - - pymetalink >=6.5.2 + - pymetalink >=6.5.3 - s3fs - salib - seaborn diff --git a/pyproject.toml b/pyproject.toml index d7d98bea..78d42efc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,7 @@ dev = [ docs = [ # Requires python >=3.11 "autodoc-pydantic >=2.1.0", - "birdhouse-birdy", + "birdhouse-birdy >=0.9.1", "cairosvg >=2.6.0", "cartopy >=0.23.0", "clisops >=0.16.1", @@ -107,15 +107,15 @@ docs = [ "intake-xarray <2.0", "ipykernel", "ipyleaflet", - "ipython >=8.5.0", + "ipython >=8.7.0", "ipywidgets", "jupyter-cache", "jupyter_client", "jupytext", - "matplotlib >=3.6.0", + "matplotlib >=3.7.0", "myst_nb", "nbsphinx >=0.9.5", - "pymetalink >=6.5.2", + "pymetalink >=6.5.3", "s3fs", "salib", "sphinx >=8.2.0", From b2e066ea6932bfbfb37c88a7bd3db6d763dc1747 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 4 Mar 2026 17:07:44 -0500 Subject: [PATCH 02/22] update dependencies, use newer xskillscore/climpred Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> --- environment-dev.yml | 4 ++-- environment-docs.yml | 4 ++-- pyproject.toml | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index a3ab9a00..3a9d6c40 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -9,7 +9,7 @@ dependencies: - cftime >=1.4.1 - cf_xarray >=0.9.3 - click >=8.2.0 - - climpred >=2.4.0 + - climpred >=2.6.0 - dask >=2024.8.1 - fiona >=1.9.0 - gdal >=3.1 @@ -38,7 +38,7 @@ dependencies: - xclim >=0.57.0 - xesmf - xsdba >=0.4.0 - - xskillscore + - xskillscore >=0.0.29 - zarr >=2.13,<3.0 # FIXME: zarr v3 does not support FSMap like before: https://github.com/zarr-developers/zarr-python/issues/2706 # Dev tools and testing - pip >=25.2 diff --git a/environment-docs.yml b/environment-docs.yml index eea225a9..08d6ea5e 100644 --- a/environment-docs.yml +++ b/environment-docs.yml @@ -16,9 +16,9 @@ dependencies: # Needed for notebooks/HydroShare_integration.ipynb # See: https://github.com/CSHS-CWRA/RavenPy/pull/326 # - "hsclient", - - intake <2.0 + - intake >=2.0 - intake-esm >=2023.07.07 - - intake-xarray <2.0 + - intake-xarray >=2.0 - ipykernel - ipyleaflet - ipython >=8.7.0 diff --git a/pyproject.toml b/pyproject.toml index 78d42efc..b240329f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ dependencies = [ # cf-xarray is differently named on conda-forge "cf-xarray >=0.9.3", "click >=8.2.0", - "climpred >=2.4.0", + "climpred >=2.6.0", "dask >=2024.8.1", "h5netcdf >=1.5.0", "haversine >=2.8.0", @@ -60,7 +60,7 @@ dependencies = [ "xarray >=2023.11.0,!=2024.10.0", "xclim >=0.57.0", "xsdba >=0.4.0", - "xskillscore" + "xskillscore >=0.0.29" ] [project.optional-dependencies] @@ -102,9 +102,9 @@ docs = [ # Needed for notebooks/HydroShare_integration.ipynb # See: https://github.com/CSHS-CWRA/RavenPy/pull/326 # "hsclient", - "intake <2.0", + "intake >=2.0", "intake-esm >=2023.07.07", - "intake-xarray <2.0", + "intake-xarray >=2.0", "ipykernel", "ipyleaflet", "ipython >=8.7.0", From 14d512f795c03d5799422d6fc904842073cbb518 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 4 Mar 2026 17:09:22 -0500 Subject: [PATCH 03/22] add new docs testing targets Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> --- .gitignore | 1 + Makefile | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 35effac7..16671f42 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,7 @@ docs/.jupyter_cache docs/apidoc/modules.rst docs/apidoc/ravenpy*.rst docs/jupyter_execute +docs/output-sanitize.cfg docs/readme.rst # PyBuilder diff --git a/Makefile b/Makefile index 2de269be..f3cf8c83 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ .PHONY: clean clean-build clean-pyc clean-test coverage dist docs help install lint lint/flake8 .DEFAULT_GOAL := help +SANITIZE_FILE := https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/raw/master/notebooks/output-sanitize.cfg + define BROWSER_PYSCRIPT import os, webbrowser, sys @@ -54,6 +56,8 @@ clean-test: ## remove test and coverage artifacts rm -fr htmlcov/ rm -fr .pytest_cache +## Testing targets: + lint/flake8: ## check style with flake8 python -m ruff check src/ravenpy tests python -m flake8 --config=.flake8 src/ravenpy tests @@ -73,7 +77,15 @@ coverage: ## check code coverage quickly with the default Python python -m coverage html $(BROWSER) htmlcov/index.html -autodoc: clean-docs ## create sphinx-apidoc files: +notebook-sanitizer: ## sanitize notebooks with configuration file + @-bash -c "curl -L $(SANITIZE_FILE) -o $(CURDIR)/docs/output-sanitize.cfg --silent" + +test-notebooks: notebook-sanitizer ## test all notebook under docs/notebooks + python -m pytest --nbval $(CURDIR)/docs/notebooks/*.ipynb --nbval-sanitize-with $(CURDIR)/docs/output-sanitize.cfg + +## Sphinx targets: + +autodoc: clean-docs ## create sphinx-apidoc files sphinx-apidoc -o docs/apidoc --private --module-first src/ravenpy autodoc-custom-index: clean-docs ## create sphinx-apidoc files but with special index handling for indices and indicators @@ -100,6 +112,8 @@ endif servedocs: docs ## compile the docs watching for changes watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . +## Development targets: + dist: clean ## builds source and wheel package python -m flit build ls -l dist From 25e63b57dcbc2913d04d1ec68bfc9a2682638ac0 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 4 Mar 2026 17:10:55 -0500 Subject: [PATCH 04/22] update notebooks for new dependencies Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> --- ...tting_and_bias_correcting_CMIP6_data.ipynb | 24 ++++++++++++------- .../11_Climatological_ESP_forecasting.ipynb | 5 +++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/notebooks/08_Getting_and_bias_correcting_CMIP6_data.ipynb b/docs/notebooks/08_Getting_and_bias_correcting_CMIP6_data.ipynb index 00c57f69..6d0c9ccb 100644 --- a/docs/notebooks/08_Getting_and_bias_correcting_CMIP6_data.ipynb +++ b/docs/notebooks/08_Getting_and_bias_correcting_CMIP6_data.ipynb @@ -365,7 +365,7 @@ "\n", " out[exp] = {}\n", " for variable in [\"tasmin\", \"tasmax\", \"pr\"]:\n", - " print(exp, variable)\n", + " print(f\"Now processing:{exp} x {variable}\")\n", " query = dict(\n", " experiment_id=exp,\n", " table_id=\"day\",\n", @@ -558,7 +558,9 @@ "cell_type": "code", "execution_count": null, "metadata": { - "tags": [] + "tags": [ + "nbval-skip" + ] }, "outputs": [], "source": [ @@ -569,7 +571,8 @@ " corrected_ref_precip.to_dataset(name=\"pr\"),\n", " corrected_ref_tasmax.to_dataset(name=\"tasmax\"),\n", " corrected_ref_tasmin.to_dataset(name=\"tasmin\"),\n", - " ]\n", + " ],\n", + " compat=\"no_conflicts\"\n", ")\n", "\n", "# Write to temporary folder.\n", @@ -581,8 +584,9 @@ " [\n", " corrected_fut_precip.to_dataset(name=\"pr\"),\n", " corrected_fut_tasmax.to_dataset(name=\"tasmax\"),\n", - " corrected_fut_tasmin.to_dataset(name=\"tasmin\"),\n", - " ]\n", + " corrected_fut_tasmin.to_dataset(name=\"tasmin\")\n", + " ],\n", + " compat=\"no_conflicts\"\n", ")\n", "\n", "fn_fut = tmp / \"future_dataset.nc\"\n", @@ -593,7 +597,9 @@ "cell_type": "code", "execution_count": null, "metadata": { - "tags": [] + "tags": [ + "nbval-skip" + ] }, "outputs": [], "source": [ @@ -605,7 +611,9 @@ "cell_type": "code", "execution_count": null, "metadata": { - "tags": [] + "tags": [ + "nbval-skip" + ] }, "outputs": [], "source": [ @@ -625,7 +633,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.13.12" } }, "nbformat": 4, diff --git a/docs/notebooks/11_Climatological_ESP_forecasting.ipynb b/docs/notebooks/11_Climatological_ESP_forecasting.ipynb index e5df4ca7..485b8b30 100644 --- a/docs/notebooks/11_Climatological_ESP_forecasting.ipynb +++ b/docs/notebooks/11_Climatological_ESP_forecasting.ipynb @@ -181,6 +181,9 @@ "# Adjust the streamflow to convert missing data from -1.2345 format to NaN. Set all negative values to NaN.\n", "q_obs = q_obs.where(q_obs > 0, np.nan)\n", "\n", + "# Drop non-numerical variable\n", + "q_sims = q_sims.drop_vars(\"basin_fullname\")\n", + "\n", "# Compute the Continuous Ranked Probability Score using xskillscore\n", "xs.crps_ensemble(q_obs, q_sims, dim=\"time\").q_sim.values[0]" ] @@ -287,7 +290,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.13.12" } }, "nbformat": 4, From 0d117c4dc4f6ed2dc371ae8cfa2b34affffbdf43 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:00:17 -0500 Subject: [PATCH 05/22] re-run notebooks --- ...xtract_geographical_watershed_properties.ipynb | 7 ++++++- ...8_Getting_and_bias_correcting_CMIP6_data.ipynb | 2 +- ...imate_change_impact_study_on_a_watershed.ipynb | 15 +++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/notebooks/02_Extract_geographical_watershed_properties.ipynb b/docs/notebooks/02_Extract_geographical_watershed_properties.ipynb index 9d02b8c2..9e09f4f9 100644 --- a/docs/notebooks/02_Extract_geographical_watershed_properties.ipynb +++ b/docs/notebooks/02_Extract_geographical_watershed_properties.ipynb @@ -407,6 +407,11 @@ } ], "metadata": { + "kernelspec": { + "display_name": "RavenPy", + "language": "python", + "name": "python3" + }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -417,7 +422,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.13.11" } }, "nbformat": 4, diff --git a/docs/notebooks/08_Getting_and_bias_correcting_CMIP6_data.ipynb b/docs/notebooks/08_Getting_and_bias_correcting_CMIP6_data.ipynb index 6d0c9ccb..069cbe10 100644 --- a/docs/notebooks/08_Getting_and_bias_correcting_CMIP6_data.ipynb +++ b/docs/notebooks/08_Getting_and_bias_correcting_CMIP6_data.ipynb @@ -365,7 +365,7 @@ "\n", " out[exp] = {}\n", " for variable in [\"tasmin\", \"tasmax\", \"pr\"]:\n", - " print(f\"Now processing:{exp} x {variable}\")\n", + " print(f\"Now processing: {exp} x {variable}\")\n", " query = dict(\n", " experiment_id=exp,\n", " table_id=\"day\",\n", diff --git a/docs/notebooks/paper/Perform_a_climate_change_impact_study_on_a_watershed.ipynb b/docs/notebooks/paper/Perform_a_climate_change_impact_study_on_a_watershed.ipynb index ca1489e8..c9140be2 100644 --- a/docs/notebooks/paper/Perform_a_climate_change_impact_study_on_a_watershed.ipynb +++ b/docs/notebooks/paper/Perform_a_climate_change_impact_study_on_a_watershed.ipynb @@ -454,7 +454,7 @@ "\n", " out[exp] = {}\n", " for variable in [\"tasmin\", \"tasmax\", \"pr\"]:\n", - " print(exp, variable)\n", + " print(f\"Now processing: {exp} x {variable}\")\n", " query = dict(\n", " experiment_id=exp,\n", " table_id=\"day\",\n", @@ -768,12 +768,6 @@ "low = (0.01, -15.0, 10.0, 0.0, 1.0, 0.0)\n", "high = (2.5, 10.0, 700.0, 7.0, 30.0, 1.0)\n", "\n", - "# Random seed.\n", - "# We will provide one for consistency purposes, but operationally this should not be provided.\n", - "# FIXME: This will change in numpy v2.0, so we will need to update this code then.\n", - "random_seed = 42\n", - "np.random.seed(random_seed)\n", - "\n", "# Build the optimizer object\n", "spot_setup = SpotSetup(\n", " config=model_config,\n", @@ -1016,6 +1010,11 @@ } ], "metadata": { + "kernelspec": { + "display_name": "RavenPy", + "language": "python", + "name": "python3" + }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -1026,7 +1025,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.9" + "version": "3.13.11" } }, "nbformat": 4, From 0bc39874a8efdb83e56807f9e88fc1b230602581 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:07:36 -0500 Subject: [PATCH 06/22] discover all notebooks, use pytest-xdist, no sanitize needed --- Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f3cf8c83..ef94bd08 100644 --- a/Makefile +++ b/Makefile @@ -77,11 +77,10 @@ coverage: ## check code coverage quickly with the default Python python -m coverage html $(BROWSER) htmlcov/index.html -notebook-sanitizer: ## sanitize notebooks with configuration file - @-bash -c "curl -L $(SANITIZE_FILE) -o $(CURDIR)/docs/output-sanitize.cfg --silent" +NOTEBOOKS := $(shell find $(CURDIR)/docs/notebooks -name '*.ipynb') -test-notebooks: notebook-sanitizer ## test all notebook under docs/notebooks - python -m pytest --nbval $(CURDIR)/docs/notebooks/*.ipynb --nbval-sanitize-with $(CURDIR)/docs/output-sanitize.cfg +test-notebooks: ## test all notebooks under docs/notebooks + python -m pytest --nbval --numprocesses=logical --maxprocesses=8 --dist=loadscope $(NOTEBOOKS) ## Sphinx targets: From 7e3479a24fcca0e9615cbf5aac8c276ccef5b16c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 16:08:48 +0000 Subject: [PATCH 07/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../02_Extract_geographical_watershed_properties.ipynb | 5 ----- ...erform_a_climate_change_impact_study_on_a_watershed.ipynb | 5 ----- 2 files changed, 10 deletions(-) diff --git a/docs/notebooks/02_Extract_geographical_watershed_properties.ipynb b/docs/notebooks/02_Extract_geographical_watershed_properties.ipynb index 9e09f4f9..b8e68304 100644 --- a/docs/notebooks/02_Extract_geographical_watershed_properties.ipynb +++ b/docs/notebooks/02_Extract_geographical_watershed_properties.ipynb @@ -407,11 +407,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "RavenPy", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", diff --git a/docs/notebooks/paper/Perform_a_climate_change_impact_study_on_a_watershed.ipynb b/docs/notebooks/paper/Perform_a_climate_change_impact_study_on_a_watershed.ipynb index c9140be2..341ed9de 100644 --- a/docs/notebooks/paper/Perform_a_climate_change_impact_study_on_a_watershed.ipynb +++ b/docs/notebooks/paper/Perform_a_climate_change_impact_study_on_a_watershed.ipynb @@ -1010,11 +1010,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "RavenPy", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", From 36603d5cbfdc3d92513df63104704ced728667c1 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:22:56 -0500 Subject: [PATCH 08/22] fix triggers --- .github/workflows/bump-version.yml | 2 +- .github/workflows/main.yml | 4 ++-- .github/workflows/scorecard.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 7eee536a..45a3b893 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -8,7 +8,7 @@ name: "Bump Patch Version" on: push: branches: - - master + - main paths-ignore: - .cruft.json - .editorconfig diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2fa651d2..a5f7ed1c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: RavenPy on: push: branches: - - master + - main pull_request: env: @@ -192,7 +192,7 @@ jobs: ~/.cache/raven-testdata key: ${{ hashFiles('src/ravenpy/testing/registry.txt') }}-${{ env.RAVEN_TESTDATA_BRANCH }}-conda-${{ matrix.os }} - - name: Prefetch RavenPy test data + - name: Prefetch RavenPy testing data run: | python -c "import ravenpy.testing.utils as rtu; rtu.populate_testing_data()" diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 650ec271..8c5a1f51 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -13,7 +13,7 @@ on: - cron: '41 8 * * 4' push: branches: - - master + - main # Read-all permission is not technically needed for this workflow. permissions: From 9bd0df2b624df78b0f036ee16034171ff51f2523 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:23:53 -0500 Subject: [PATCH 09/22] add notebook testing workflow --- .github/workflows/notebooks.yml | 86 +++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/notebooks.yml diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml new file mode 100644 index 00000000..a5c1b47e --- /dev/null +++ b/.github/workflows/notebooks.yml @@ -0,0 +1,86 @@ +name: RavenPy + +on: + push: + branches: + - main + pull_request: + schedule: + - cron: '0 9 * * 1' + +env: + RAVEN_TESTDATA_BRANCH: v2025.6.12 + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + +permissions: + contents: read + +jobs: + notebooks: + name: Test Notebooks (Anaconda, ${{ matrix.os }}) + needs: lint + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ "ubuntu-latest", "macos-latest" ] + python-version: [ "3.14" ] + defaults: + run: + shell: bash -l {0} + steps: + - name: Harden Runner + uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2 + with: + disable-sudo: true + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Setup Conda (Micromamba) with Python${{ matrix.python-version }} + uses: mamba-org/setup-micromamba@add3a49764cedee8ee24e82dfde87f5bc2914462 # v2.0.7 + with: + cache-downloads: true + cache-environment: true + cache-environment-key: environment-${{ matrix.python-version }}-${{ matrix.os }}-${{ github.head_ref }} + environment-file: environment-dev.yml + create-args: >- + python=${{ matrix.python-version }} + + - name: Install RavenPy + run: | + python -m pip install --editable --no-deps . + + - name: List installed packages + run: | + micromamba list + python -m pip check || true + + - name: Cache test data (macOS) + if: matrix.os == 'macos-latest' + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + with: + path: | + ~/Library/Caches/raven-testdata + key: ${{ hashFiles('src/ravenpy/testing/registry.txt') }}-${{ env.RAVEN_TESTDATA_BRANCH }}-conda-${{ matrix.os }} + - name: Cache test data (Ubuntu) + if: matrix.os == 'ubuntu-latest' + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + with: + path: | + ~/.cache/raven-testdata + key: ${{ hashFiles('src/ravenpy/testing/registry.txt') }}-${{ env.RAVEN_TESTDATA_BRANCH }}-conda-${{ matrix.os }} + + - name: Prefetch RavenPy testing data + run: | + python -c "import ravenpy.testing.utils as rtu; rtu.populate_testing_data()" + + - name: Test RavenPy + run: | + make test-notebooks From 6773b6aac974d9088a7d9f45ab1ac243c14e68f0 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:57:14 -0500 Subject: [PATCH 10/22] remove inexistent job --- .github/workflows/notebooks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index a5c1b47e..d6c518b3 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -21,7 +21,6 @@ permissions: jobs: notebooks: name: Test Notebooks (Anaconda, ${{ matrix.os }}) - needs: lint runs-on: ${{ matrix.os }} strategy: fail-fast: false From 83c670bc4585e80f9bab4d724a0d0af7d298a684 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 12:15:17 -0500 Subject: [PATCH 11/22] remove artifacts --- .gitignore | 1 - Makefile | 2 -- 2 files changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 16671f42..35effac7 100644 --- a/.gitignore +++ b/.gitignore @@ -74,7 +74,6 @@ docs/.jupyter_cache docs/apidoc/modules.rst docs/apidoc/ravenpy*.rst docs/jupyter_execute -docs/output-sanitize.cfg docs/readme.rst # PyBuilder diff --git a/Makefile b/Makefile index ef94bd08..26aa8e8d 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,6 @@ .PHONY: clean clean-build clean-pyc clean-test coverage dist docs help install lint lint/flake8 .DEFAULT_GOAL := help -SANITIZE_FILE := https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/raw/master/notebooks/output-sanitize.cfg - define BROWSER_PYSCRIPT import os, webbrowser, sys From 7312a44faed23c49e14a8d2cd4a80ca517ab4ffe Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 12:15:38 -0500 Subject: [PATCH 12/22] update CHANGELOG.rst --- CHANGELOG.rst | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 92ab2a76..df568f4b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,19 +2,26 @@ Changelog ========= -.. - `Unreleased `_ (latest) - ------------------------------------------------------------- +`Unreleased `_ (latest) +------------------------------------------------------------- - Contributors: +Contributors: Trevor James Smith (:user:`Zeitsperre`). + +Changes +^^^^^^^ +* Dependency updates. (PR #584): + * Updated required `xskillscore` (``>= 0.0.29``) and `climpred` (``>= 2.6.0``). + * Removed version pins on `intake` and `intake-xarray`. + * Minimum required `birdy` is now ``>= 0.9.1``. - Changes - ^^^^^^^ - * No change. +Fixes +^^^^^ +* Updated notebooks to address several deprecation warnings stemming from `dask`, `numpy`, and `xarray`. (PR #584) - Fixes - ^^^^^ - * No change. +Internal changes +^^^^^^^^^^^^^^^^ +* Added a Makefile recipe and a GitHub Workflow to run tests against the notebooks using ``pytest --nbval`` on changes as well as on a weekly schedule. (PR #584) +* Fixed a bug in several workflows that was impeding triggers when Pull Requests are merged to `main`. (PR #584) .. _changes_0.20.0: @@ -42,15 +49,15 @@ Fixes Internal changes ^^^^^^^^^^^^^^^^ * Updated the cookiecutter template to the latest version (PR #548): - * Updated the Contributor Covenant Agreement to v3.0. - * Added a `CITATION.cff` file. - * Removed `black`, `blackdoc`, and `isort`, as well as their configurations. - * Updated `pyproject.toml` to be `PEP 639 `_-compliant. + * Updated the Contributor Covenant Agreement to v3.0. + * Added a `CITATION.cff` file. + * Removed `black`, `blackdoc`, and `isort`, as well as their configurations. + * Updated `pyproject.toml` to be `PEP 639 `_-compliant. * Pinned `pydantic` below v2.12 due to breaking changes in their API. (PR #548) - * Unpinned `pydantic` as newer 2.12 patch releases appear to have addressed regressions. (PR #559) + * Unpinned `pydantic` as newer 2.12 patch releases appear to have addressed regressions. (PR #559) * Pinned `pydap` >=3.5.6 and `h5netcdf` >=1.5.0 to ensure modern versions with better `xarray` support are installed by default. (PR #559) * Updated the cookiecutter template to the latest version (PR #569): - * Added a workflow for automatically accepting and merging periodic updates from Dependabot affecting CI dependencies. + * Added a workflow for automatically accepting and merging periodic updates from Dependabot affecting CI dependencies. * Added a `pytest` fixture to perform a teardown of changes performed within the installed `ravenpy` source location. (PR #572) .. _changes_0.19.1: From b22519430ebf982c90f271a56c814c29dd13f0a9 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 12:17:25 -0500 Subject: [PATCH 13/22] rename workflows --- .github/workflows/main.yml | 2 +- .github/workflows/notebooks.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a5f7ed1c..67879a7c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: RavenPy +name: Testing on: push: diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index d6c518b3..6e1bcad4 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -1,4 +1,4 @@ -name: RavenPy +name: Notebooks on: push: From 64959333f34c834aefd2a07b3bd951f631ccca70 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 13:23:41 -0500 Subject: [PATCH 14/22] order is important --- .github/workflows/notebooks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index 6e1bcad4..344a798e 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -54,7 +54,7 @@ jobs: - name: Install RavenPy run: | - python -m pip install --editable --no-deps . + python -m pip install --no-deps --editable . - name: List installed packages run: | From fa14664cda513700eaf10a1d1571a4cbf644bfdc Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:28:05 -0500 Subject: [PATCH 15/22] split notebook deps --- environment-dev.yml | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index 3a9d6c40..78de90fd 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -5,32 +5,22 @@ dependencies: - python >=3.10,<3.15 - raven-hydro >=0.5.0,<1.0 # - libgcc # for mixing raven-hydro from PyPI with conda environments - - affine >=2.4.0 - cftime >=1.4.1 - cf_xarray >=0.9.3 - click >=8.2.0 - climpred >=2.6.0 - dask >=2024.8.1 - - fiona >=1.9.0 - - gdal >=3.1 - - geopandas >=1.0 - h5netcdf >=1.3.0 - haversine >=2.8.0 - matplotlib-base >=3.6.0 - - netcdf4 >=1.7.2 - numpy >=1.25.0 - owslib >=0.29.1 - pandas >=2.2.0 - pint >=0.24.4 - pydantic >=2.11 - pydap >=3.5.6 - - pymetalink >=6.5.2 - pymbolic >=2024.2 - - pyproj >=3.3.0 - - rasterio - - rioxarray - scipy >=1.11.0 - - shapely >=2.0.0 - spotpy >=1.6.1 - statsmodels >=0.14.2 - typing_extensions @@ -39,7 +29,7 @@ dependencies: - xesmf - xsdba >=0.4.0 - xskillscore >=0.0.29 - - zarr >=2.13,<3.0 # FIXME: zarr v3 does not support FSMap like before: https://github.com/zarr-developers/zarr-python/issues/2706 + - zarr >=3.0 # Dev tools and testing - pip >=25.2 - bump-my-version >=1.2.3 @@ -50,10 +40,7 @@ dependencies: - flake8 >=7.3.0 - flake8-rst-docstrings >=0.4.0 - flit >=3.11.0,<4.0 - - holoviews - - hvplot - mypy >=1.18.2 - - nbval - numpydoc >=1.9.0 - pooch >=1.8.0 - pre-commit >=3.5.0 @@ -62,7 +49,33 @@ dependencies: - pytest-cov >=5.0.0 - pytest-xdist >=3.2.0 - ruff >=0.13.3 - - setuptools >=71.0 - tox >=4.30.3 - vulture >=2.14 - watchdog >=4.0.0 + # GIS support + - affine >=2.4.0 + - fiona >=1.9.0 + - gdal >=3.1 + - geopandas >=1.0 + - lxml + - netcdf4 >=1.7.2 + - pyproj >=3.3.0 + - rasterio + - rioxarray + - setuptools >=71.0 + - shapely >=2.0.0 + # Notebook support + - birdy >=0.9.1 + - clisops >=0.16.1 + - gcsfs + - holoviews + - hvplot + - intake >=2.0 + - intake-esm >=2023.07.07 + - intake-xarray >=2.0 + - iprogress + - ipyleaflet + - nbval + - pymetalink >=6.5.3 + - s3fs + - salib From 0fb1f7359ddfd9058d94078b7e7d2be0f81b73ab Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:29:15 -0500 Subject: [PATCH 16/22] install only deps needed for build and rendering --- docs/conf.py | 43 ++++++++++------------------------- environment-docs.yml | 53 +++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 61 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 9e146692..183b6a38 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -101,10 +101,6 @@ def rebuild_readme(): "notebooks/paper/*.ipynb", ] -# nbsphinx_execute = "auto" -# nbsphinx_timeout = 1 -# nbsphinx_allow_errors = True - extlinks = { "issue": ("https://github.com/CSHS-CWRA/RavenPy/issues/%s", "GH/%s"), "pull": ("https://github.com/CSHS-CWRA/RavenPy/pull/%s", "PR/%s"), @@ -121,33 +117,18 @@ def rebuild_readme(): # To avoid having to install these and burst memory limit on ReadTheDocs. autodoc_mock_imports = [ - "affine", - "cftime", - "cf_xarray", - "click", - "climpred", - "clisops", - "fiona", - "gdal", - "h5netcdf", - "netCDF4", - "osgeo", - "geopandas", - "haversine", - "holoviews", - "hvplot", - "lxml", - "owslib", - "pandas", - "pyproj", - "rasterio", - "rioxarray", - "scipy", - "shapely", - "spotpy", - "statsmodels", - "xarray", - "xclim", + "affine", + "fiona", + "geopandas", + "holoviews", + "hvplot", + "lxml", + "osgeo", + "netCDF4", + "pyproj", + "rasterio", + "rioxarray", + "shapely" ] # Add any paths that contain templates here, relative to this directory. diff --git a/environment-docs.yml b/environment-docs.yml index 08d6ea5e..3d59a5a6 100644 --- a/environment-docs.yml +++ b/environment-docs.yml @@ -4,46 +4,39 @@ channels: dependencies: - python >=3.13,<3.14 - raven-hydro >=0.5.0,<1.0 - - autodoc-pydantic >=2.1.0 - - birdy >=0.9.1 - - cairosvg >=2.6.0 - - cartopy >=0.23.0 + - cftime >=1.4.1 + - cf-xarray >=0.9.3 - click >=8.2.0 - - clisops >=0.16.1 - - gcsfs - - gdal >=3.1 + - climpred >=2.6.0 + - dask >=2024.8.1 - h5netcdf >=1.5.0 + - haversine >=2.8.0 + - matplotlib >=3.6.0 + - numpy >=1.25.0 + - owslib >=0.29.1 + - pandas >=2.2.0 + - pint >=0.24.4 + - pydantic >=2.11 + - pydap >=3.5.6 + - pymbolic >=2024.2 + - scipy >=1.11.0 + - spotpy >=1.6.1 + - statsmodels >=0.14.2 + - typing-extensions + - xarray >=2023.11.0,!=2024.10.0 + - xclim >=0.57.0 + - xsdba >=0.4.0 + - xskillscore >=0.0.29 # Needed for notebooks/HydroShare_integration.ipynb # See: https://github.com/CSHS-CWRA/RavenPy/pull/326 # - "hsclient", - - intake >=2.0 - - intake-esm >=2023.07.07 - - intake-xarray >=2.0 - - ipykernel - - ipyleaflet - - ipython >=8.7.0 - - jupyter-cache - - jupyter_client - - jupytext + - autodoc-pydantic >=2.1.0 - matplotlib-base >=3.7.0 - myst-nb - - nbsphinx >=0.9.5 - - netCDF4 >=1.7.2 - - numpy >=1.25.0 - - notebook - - pandas >=2.2 - - pydantic >=2.11 - - pymetalink >=6.5.3 - - s3fs - - salib - - seaborn + - nbsphinx >=0.9.8 - sphinx >=8.2.0 - sphinx-click - sphinx-codeautolink >=0.16.2 - sphinx-copybutton - sphinx-rtd-theme >=1.0 - sphinxcontrib-svg2pdfconverter >=1.2.3 - - typing_extensions - - xarray >=2023.11.0,!=2024.10.0 -# - xesmf # mocked - - zarr >=2.13,<3.0 # FIXME: zarr v3 does not support FSMap like before: https://github.com/zarr-developers/zarr-python/issues/2706 From 69b0575ccadf472032a0ca1c4f833a2944222ddf Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:29:25 -0500 Subject: [PATCH 17/22] simplify browser call --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 26aa8e8d..b1858630 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ import os, webbrowser, sys from urllib.request import pathname2url -webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) +webbrowser.open(sys.argv[1]) endef export BROWSER_PYSCRIPT From 1f0d0a21eb9a6bf802960368375722809877175f Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:42:47 -0500 Subject: [PATCH 18/22] downgrade python version in build --- .github/workflows/notebooks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index 344a798e..ead97b00 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -26,7 +26,7 @@ jobs: fail-fast: false matrix: os: [ "ubuntu-latest", "macos-latest" ] - python-version: [ "3.14" ] + python-version: [ "3.13" ] # pymetalink not yet supported in Python 3.14 defaults: run: shell: bash -l {0} From e73115f7b8f6e266abb54b62f5e9c027a2430013 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:51:28 -0500 Subject: [PATCH 19/22] unpin zarr, add seaborn for notebook --- environment-dev.yml | 2 +- environment-docs.yml | 2 ++ pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index 78de90fd..16eceb48 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -29,7 +29,7 @@ dependencies: - xesmf - xsdba >=0.4.0 - xskillscore >=0.0.29 - - zarr >=3.0 + - zarr # Dev tools and testing - pip >=25.2 - bump-my-version >=1.2.3 diff --git a/environment-docs.yml b/environment-docs.yml index 3d59a5a6..398d539a 100644 --- a/environment-docs.yml +++ b/environment-docs.yml @@ -40,3 +40,5 @@ dependencies: - sphinx-copybutton - sphinx-rtd-theme >=1.0 - sphinxcontrib-svg2pdfconverter >=1.2.3 +# Needed for notebooks/Managing_Jupyter_Environments.ipynb + - seaborn diff --git a/pyproject.toml b/pyproject.toml index b240329f..b057b04c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -125,7 +125,7 @@ docs = [ "sphinx-rtd-theme >=1.0", "sphinxcontrib-svg2pdfconverter >=1.2.3", "xesmf", - "zarr >=2.10.0,<3.0" # FIXME: zarr v3 does not support FSMap like before: https://github.com/zarr-developers/zarr-python/issues/2706 + "zarr" ] gis = [ "affine >=2.4.0", From a5862c16cc51d0c9736633fbb430cdd115aceff2 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 16:09:17 -0500 Subject: [PATCH 20/22] seaborn needed for nb example --- environment-dev.yml | 2 ++ environment-docs.yml | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index 16eceb48..270af7b5 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -79,3 +79,5 @@ dependencies: - pymetalink >=6.5.3 - s3fs - salib +# Needed for notebooks/Managing_Jupyter_Environments.ipynb + - seaborn diff --git a/environment-docs.yml b/environment-docs.yml index 398d539a..108d1749 100644 --- a/environment-docs.yml +++ b/environment-docs.yml @@ -30,6 +30,7 @@ dependencies: # Needed for notebooks/HydroShare_integration.ipynb # See: https://github.com/CSHS-CWRA/RavenPy/pull/326 # - "hsclient", + # Docs support - autodoc-pydantic >=2.1.0 - matplotlib-base >=3.7.0 - myst-nb @@ -40,5 +41,3 @@ dependencies: - sphinx-copybutton - sphinx-rtd-theme >=1.0 - sphinxcontrib-svg2pdfconverter >=1.2.3 -# Needed for notebooks/Managing_Jupyter_Environments.ipynb - - seaborn From 9f66e1a318e80648d6fbfcb97e683f15cdb7d2b0 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:08:55 -0500 Subject: [PATCH 21/22] dev recipe no longer required --- .readthedocs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index cc7338d3..7b442385 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -33,5 +33,4 @@ python: - method: pip path: . extra_requirements: - - dev - docs From 2e1d1fda1962d901aa17e53fd10c4fafa179b911 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 10 Mar 2026 14:08:35 -0400 Subject: [PATCH 22/22] update CHANGELOG.rst, fix doc warning Signed-off-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> --- CHANGELOG.rst | 2 ++ docs/conf.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index df568f4b..e1464bdb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,11 +17,13 @@ Changes Fixes ^^^^^ * Updated notebooks to address several deprecation warnings stemming from `dask`, `numpy`, and `xarray`. (PR #584) +* Adjusted notebook execution with `nbval` to reduce the computational load from remote data download calls. (PR #584) Internal changes ^^^^^^^^^^^^^^^^ * Added a Makefile recipe and a GitHub Workflow to run tests against the notebooks using ``pytest --nbval`` on changes as well as on a weekly schedule. (PR #584) * Fixed a bug in several workflows that was impeding triggers when Pull Requests are merged to `main`. (PR #584) +* The conda configurations (``environment-dev.yml`` and ``environment-docs.yml``) now specify the exact dependencies needed to run the development and documentation builds. (PR #584) .. _changes_0.20.0: diff --git a/docs/conf.py b/docs/conf.py index 183b6a38..973e9b4d 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -42,7 +42,8 @@ def rebuild_readme(): # Remove the badge table readme = readme.replace( - "=======\nRavenPy\n=======", "=======\nRavenPy\n=======\n\n.. only:: not latex" + "==============\nRavenPy |logo|\n==============", + "==============\nRavenPy |logo|\n==============\n\n.. only:: not latex" ) readme = readme.replace("\n+-", "\n +-") readme = readme.replace("\n|", "\n |")