From c563377f879d744c19511fd4b74c7fe1f0724a47 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:15:09 -0400 Subject: [PATCH 01/48] WIP - integrate energy measurements --- .github/workflows/main.yml | 131 +++++++++++++++++++++++++++++++------ 1 file changed, 110 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e4ab2a82..98fb55c89 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,6 +52,12 @@ jobs: files.pythonhosted.org:443 github.com:443 pypi.org:443 + - name: Start Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: start-measurement + label: 'Linting (Python${{ matrix.python-version }})' + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Python${{ matrix.python-version }} @@ -61,12 +67,29 @@ jobs: - name: Install CI libraries run: | python -m pip install --require-hashes -r CI/requirements_ci.txt + - name: Setup Python Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'environment setup' + continue-on-error: true - name: Run pylint run: | python -m pylint --rcfile=.pylintrc.toml --disable=import-error --exit-zero xclim - name: Run linting suite run: | python -m tox -e lint + - name: Tests measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'linting' + continue-on-error: true + - name: Show Energy Results + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: display-results + continue-on-error: true test-preliminary: name: Python${{ matrix.python-version }} (ubuntu-latest) @@ -89,6 +112,13 @@ jobs: github.com:443 pypi.org:443 raw.githubusercontent.com:443 + - name: Start Energy Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: start-measurement + label: 'preliminary tests' + branch: ${{ github.event.pull_request.head.ref }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Python${{ matrix.python-version }} @@ -98,11 +128,28 @@ jobs: - name: Install CI libraries run: | python -m pip install --require-hashes -r CI/requirements_ci.txt + - name: Environment Setup Energy Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'environment setup' + continue-on-error: true - name: Test with tox run: | python -m tox -- -m 'not slow' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Tests measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'test with tox' + continue-on-error: true + - name: Show Energy Results + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: display-results + continue-on-error: true test-pypi: needs: lint @@ -170,6 +217,12 @@ jobs: ppa.launchpadcontent.net:443 pypi.org:443 raw.githubusercontent.com:443 + - name: Start Energy Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: start-measurement + branch: ${{ github.event.pull_request.head.ref }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Eigen3 (SBCK) @@ -184,6 +237,12 @@ jobs: - name: Install CI libraries run: | python -m pip install --require-hashes -r CI/requirements_ci.txt + - name: Environment Setup Energy Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'environment setup' + continue-on-error: true - name: Test with tox if: ${{ matrix.tox-env == 'standard' }} run: | @@ -202,6 +261,17 @@ jobs: COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.tox-env }} COVERALLS_PARALLEL: true COVERALLS_SERVICE_NAME: github + - name: Tests measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'testing with tox' + continue-on-error: true + - name: Show Energy Results + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: display-results + continue-on-error: true test-conda: needs: lint @@ -235,6 +305,12 @@ jobs: pypi.org:443 raw.githubusercontent.com:443 repo.anaconda.com:443 + - name: Start Energy Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: start-measurement + branch: ${{ github.event.pull_request.head.ref }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Conda (Micromamba) with Python${{ matrix.python-version }} @@ -245,9 +321,6 @@ jobs: environment-file: environment.yml create-args: >- python=${{ matrix.python-version }} - - name: Micromamba version - run: | - echo "micromamba: $(micromamba --version)" - name: Install xclim run: | python -m pip install --no-user --editable . @@ -256,21 +329,15 @@ jobs: micromamba list xclim show_version_info python -m pip check || true + - name: Environment Setup Energy Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'environment setup' + continue-on-error: true - name: Test with pytest run: | python -m pytest --numprocesses=logical --durations=10 --cov=xclim --cov-report=term-missing -# - name: Install tox -# shell: bash -l {0} -# run: | -# mamba install -n xclim39 tox tox-conda -# - name: Test -# shell: bash -l {0} -# run: | -# conda activate xclim39 -# tox -e opt-slow -# env: -# CONDA_EXE: mamba -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Report coverage run: | coveralls @@ -279,6 +346,17 @@ jobs: COVERALLS_FLAG_NAME: run-{{ matrix.python-version }}-conda COVERALLS_PARALLEL: true COVERALLS_SERVICE_NAME: github + - name: Tests measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'testing with pytest (conda)' + continue-on-error: true + - name: Show Energy Results + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: display-results + continue-on-error: true finish: needs: @@ -288,6 +366,12 @@ jobs: runs-on: ubuntu-latest container: python:3-slim steps: + - name: Start Energy Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: start-measurement + branch: ${{ github.event.pull_request.head.ref }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: @@ -296,9 +380,14 @@ jobs: - name: Install CI libraries run: | python -m pip install --require-hashes -r CI/requirements_ci.txt - - name: Coveralls finished - run: | - python -m coveralls --finish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_SERVICE_NAME: github + - name: Finish measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'finish' + continue-on-error: true + - name: Show Energy Results + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: display-results + continue-on-error: true From eefceaf053ae082019a43412fcb4d29c9870c73a Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:23:47 -0400 Subject: [PATCH 02/48] WIP - audit connections --- .github/workflows/main.yml | 57 +++++++++----------------------------- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 98fb55c89..97bc7b593 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,17 +47,14 @@ jobs: uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 with: disable-sudo: true - egress-policy: block - allowed-endpoints: > - files.pythonhosted.org:443 - github.com:443 - pypi.org:443 + egress-policy: audit + - name: Start Measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement label: 'Linting (Python${{ matrix.python-version }})' - continue-on-error: true + - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Python${{ matrix.python-version }} @@ -104,21 +101,15 @@ jobs: uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 with: disable-sudo: true - egress-policy: block - allowed-endpoints: > - api.github.com:443 - dap.service.does.not.exist:443 - files.pythonhosted.org:443 - github.com:443 - pypi.org:443 - raw.githubusercontent.com:443 + egress-policy: audit + - name: Start Energy Measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement label: 'preliminary tests' branch: ${{ github.event.pull_request.head.ref }} - continue-on-error: true + - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Python${{ matrix.python-version }} @@ -203,26 +194,14 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 with: - egress-policy: block - allowed-endpoints: > - api.github.com:443 - azure.archive.ubuntu.com:80 - coveralls.io:443 - dap.service.does.not.exist:443 - esm.ubuntu.com:443 - files.pythonhosted.org:443 - github.com:443 - motd.ubuntu.com:443 - packages.microsoft.com:443 - ppa.launchpadcontent.net:443 - pypi.org:443 - raw.githubusercontent.com:443 + egress-policy: audit + - name: Start Energy Measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement branch: ${{ github.event.pull_request.head.ref }} - continue-on-error: true + - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Eigen3 (SBCK) @@ -293,24 +272,14 @@ jobs: uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 with: disable-sudo: true - egress-policy: block - allowed-endpoints: > - api.github.com:443 - conda.anaconda.org:443 - coveralls.io:443 - dap.service.does.not.exist:443 - files.pythonhosted.org:443 - github.com:443 - objects.githubusercontent.com:443 - pypi.org:443 - raw.githubusercontent.com:443 - repo.anaconda.com:443 + egress-policy: audit + - name: Start Energy Measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement branch: ${{ github.event.pull_request.head.ref }} - continue-on-error: true + - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Conda (Micromamba) with Python${{ matrix.python-version }} @@ -371,7 +340,7 @@ jobs: with: task: start-measurement branch: ${{ github.event.pull_request.head.ref }} - continue-on-error: true + - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: From d9bae89cfeb093c1faed851c6b22d7b1cb4bd345 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:42:59 -0400 Subject: [PATCH 03/48] WIP - secure endpoints --- .github/workflows/main.yml | 48 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 97bc7b593..5fa60652b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,14 +47,22 @@ jobs: uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 with: disable-sudo: true - egress-policy: audit - + egress-policy: block + allowed-endpoints: > + api.electricitymap.org:443 + api.github.com:443 + api.green-coding.io:443 + files.pythonhosted.org:443 + github.com:443 + ip-api.com:80 + proxy.golang.org:443 + pypi.org:443 + sum.golang.org:443 - name: Start Measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement label: 'Linting (Python${{ matrix.python-version }})' - - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Python${{ matrix.python-version }} @@ -69,7 +77,6 @@ jobs: with: task: get-measurement label: 'environment setup' - continue-on-error: true - name: Run pylint run: | python -m pylint --rcfile=.pylintrc.toml --disable=import-error --exit-zero xclim @@ -81,12 +88,10 @@ jobs: with: task: get-measurement label: 'linting' - continue-on-error: true - name: Show Energy Results uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results - continue-on-error: true test-preliminary: name: Python${{ matrix.python-version }} (ubuntu-latest) @@ -98,11 +103,22 @@ jobs: - "3.9" steps: - name: Harden Runner - uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true - egress-policy: audit - + egress-policy: block + allowed-endpoints: > + api.electricitymap.org:443 + api.github.com:443 + api.green-coding.io:443 + coveralls.io:443 + files.pythonhosted.org:443 + github.com:443 + ip-api.com:80 + proxy.golang.org:443 + pypi.org:443 + raw.githubusercontent.com:443 + sum.golang.org:443 - name: Start Energy Measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: @@ -124,7 +140,6 @@ jobs: with: task: get-measurement label: 'environment setup' - continue-on-error: true - name: Test with tox run: | python -m tox -- -m 'not slow' @@ -135,12 +150,10 @@ jobs: with: task: get-measurement label: 'test with tox' - continue-on-error: true - name: Show Energy Results uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results - continue-on-error: true test-pypi: needs: lint @@ -201,7 +214,6 @@ jobs: with: task: start-measurement branch: ${{ github.event.pull_request.head.ref }} - - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Eigen3 (SBCK) @@ -221,7 +233,6 @@ jobs: with: task: get-measurement label: 'environment setup' - continue-on-error: true - name: Test with tox if: ${{ matrix.tox-env == 'standard' }} run: | @@ -245,12 +256,10 @@ jobs: with: task: get-measurement label: 'testing with tox' - continue-on-error: true - name: Show Energy Results uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results - continue-on-error: true test-conda: needs: lint @@ -279,7 +288,6 @@ jobs: with: task: start-measurement branch: ${{ github.event.pull_request.head.ref }} - - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Conda (Micromamba) with Python${{ matrix.python-version }} @@ -303,7 +311,6 @@ jobs: with: task: get-measurement label: 'environment setup' - continue-on-error: true - name: Test with pytest run: | python -m pytest --numprocesses=logical --durations=10 --cov=xclim --cov-report=term-missing @@ -320,12 +327,10 @@ jobs: with: task: get-measurement label: 'testing with pytest (conda)' - continue-on-error: true - name: Show Energy Results uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results - continue-on-error: true finish: needs: @@ -340,7 +345,6 @@ jobs: with: task: start-measurement branch: ${{ github.event.pull_request.head.ref }} - - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: @@ -354,9 +358,7 @@ jobs: with: task: get-measurement label: 'finish' - continue-on-error: true - name: Show Energy Results uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results - continue-on-error: true From a9a6101d74ac27218038651fe3c6e21622d8d231 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:50:23 -0400 Subject: [PATCH 04/48] WIP - is coveralls service name required? --- .github/workflows/main.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5fa60652b..f13049cd5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -125,7 +125,6 @@ jobs: task: start-measurement label: 'preliminary tests' branch: ${{ github.event.pull_request.head.ref }} - - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Python${{ matrix.python-version }} @@ -145,6 +144,8 @@ jobs: python -m tox -- -m 'not slow' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.tox-env }} + COVERALLS_PARALLEL: true - name: Tests measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: @@ -241,7 +242,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.tox-env }} COVERALLS_PARALLEL: true - COVERALLS_SERVICE_NAME: github - name: Test with tox (specialized tests) if: ${{ matrix.tox-env != 'standard' }} run: | @@ -250,7 +250,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.tox-env }} COVERALLS_PARALLEL: true - COVERALLS_SERVICE_NAME: github - name: Tests measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: @@ -321,7 +320,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_FLAG_NAME: run-{{ matrix.python-version }}-conda COVERALLS_PARALLEL: true - COVERALLS_SERVICE_NAME: github - name: Tests measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: @@ -353,6 +351,11 @@ jobs: - name: Install CI libraries run: | python -m pip install --require-hashes -r CI/requirements_ci.txt + - name: Coveralls finished + run: | + python -m coveralls --finish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Finish measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: From f772cfe642eacbf6291600f100b5e45ab26f64ef Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:27:23 -0400 Subject: [PATCH 05/48] WIP - do not run metrics on Windows/macOS --- .github/workflows/main.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f13049cd5..db047b790 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -211,6 +211,7 @@ jobs: egress-policy: audit - name: Start Energy Measurement + if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement @@ -218,7 +219,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Eigen3 (SBCK) - if: ${{ matrix.python-version == '3.11' }} + if: (matrix.python-version == '3.11') && (matrix.os == 'ubuntu-latest') run: | sudo apt-get update sudo apt-get install libeigen3-dev @@ -230,6 +231,7 @@ jobs: run: | python -m pip install --require-hashes -r CI/requirements_ci.txt - name: Environment Setup Energy Measurement + if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement @@ -251,11 +253,13 @@ jobs: COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.tox-env }} COVERALLS_PARALLEL: true - name: Tests measurement + if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement label: 'testing with tox' - name: Show Energy Results + if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results @@ -283,6 +287,7 @@ jobs: egress-policy: audit - name: Start Energy Measurement + if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement @@ -306,6 +311,7 @@ jobs: xclim show_version_info python -m pip check || true - name: Environment Setup Energy Measurement + if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement @@ -321,11 +327,13 @@ jobs: COVERALLS_FLAG_NAME: run-{{ matrix.python-version }}-conda COVERALLS_PARALLEL: true - name: Tests measurement + if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement label: 'testing with pytest (conda)' - name: Show Energy Results + if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results From 60395743ea91ab1e130c13968f12ad1e0cd527c3 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 1 Aug 2024 17:15:53 -0400 Subject: [PATCH 06/48] WIP - proper labelling --- .github/workflows/main.yml | 104 +++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 28 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index db047b790..f33b61343 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -62,7 +62,8 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement - label: 'Linting (Python${{ matrix.python-version }})' + branch: ${{ github.head_ref || github.ref_name }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Python${{ matrix.python-version }} @@ -76,7 +77,8 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'environment setup' + label: 'Environment setup (Python${{ matrix.python-version }}, lint)' + continue-on-error: true - name: Run pylint run: | python -m pylint --rcfile=.pylintrc.toml --disable=import-error --exit-zero xclim @@ -87,11 +89,13 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'linting' + label: 'Lint (Python${{ matrix.python-version }})' + continue-on-error: true - name: Show Energy Results uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results + continue-on-error: true test-preliminary: name: Python${{ matrix.python-version }} (ubuntu-latest) @@ -123,8 +127,8 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement - label: 'preliminary tests' - branch: ${{ github.event.pull_request.head.ref }} + branch: ${{ github.head_ref || github.ref_name }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Python${{ matrix.python-version }} @@ -138,7 +142,8 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'environment setup' + label: 'Environment setup (Python${{ matrix.python-version }}, standard)' + continue-on-error: true - name: Test with tox run: | python -m tox -- -m 'not slow' @@ -150,11 +155,13 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'test with tox' + label: 'Testing with tox (Python${{ matrix.python-version }})' + continue-on-error: true - name: Show Energy Results uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results + continue-on-error: true test-pypi: needs: lint @@ -206,16 +213,32 @@ jobs: tox-env: doctests steps: - name: Harden Runner - uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + if : ${{ matrix.os == 'ubuntu-latest' }} + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: - egress-policy: audit - + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.electricitymap.org:443 + api.github.com:443 + api.green-coding.io:443 + azure.archive.ubuntu.com:80 + coveralls.io:443 + files.pythonhosted.org:443 + github.com:443 + ip-api.com:80 + motd.ubuntu.com:443 + proxy.golang.org:443 + pypi.org:443 + raw.githubusercontent.com:443 + sum.golang.org:443 - name: Start Energy Measurement if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement - branch: ${{ github.event.pull_request.head.ref }} + branch: ${{ github.head_ref || github.ref_name }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Eigen3 (SBCK) @@ -235,7 +258,8 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'environment setup' + label: 'Environment setup (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})' + continue-on-error: true - name: Test with tox if: ${{ matrix.tox-env == 'standard' }} run: | @@ -257,24 +281,25 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'testing with tox' + label: 'Testing with tox (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})' + continue-on-error: true - name: Show Energy Results if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results + continue-on-error: true test-conda: needs: lint - name: Python${{ matrix.python-version }} (${{ matrix.os }}, conda) + name: Python${{ matrix.python-version }} (ubuntu-latest, conda) if: | contains(github.event.pull_request.labels.*.name, 'approved') || (github.event.review.state == 'approved') || (github.event_name == 'push') - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest strategy: matrix: - os: [ ubuntu-latest ] python-version: [ "3.9", "3.12" ] defaults: run: @@ -284,14 +309,26 @@ jobs: uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 with: disable-sudo: true - egress-policy: audit - + egress-policy: block + allowed-endpoints: > + api.electricitymap.org:443 + api.github.com:443 + api.green-coding.io:443 + coveralls.io:443 + files.pythonhosted.org:443 + github.com:443 + ip-api.com:80 + objects.githubusercontent.com:443 + proxy.golang.org:443 + pypi.org:443 + raw.githubusercontent.com:443 + sum.golang.org:443 - name: Start Energy Measurement - if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement - branch: ${{ github.event.pull_request.head.ref }} + branch: ${{ github.head_ref || github.ref_name }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Conda (Micromamba) with Python${{ matrix.python-version }} @@ -311,11 +348,11 @@ jobs: xclim show_version_info python -m pip check || true - name: Environment Setup Energy Measurement - if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'environment setup' + label: 'Environment setup (conda, Python${{ matrix.python-version }})' + continue-on-error: true - name: Test with pytest run: | python -m pytest --numprocesses=logical --durations=10 --cov=xclim --cov-report=term-missing @@ -327,30 +364,38 @@ jobs: COVERALLS_FLAG_NAME: run-{{ matrix.python-version }}-conda COVERALLS_PARALLEL: true - name: Tests measurement - if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'testing with pytest (conda)' + label: 'Testing with pytest (conda, Python${{ matrix.python-version }})' + continue-on-error: true - name: Show Energy Results - if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results + continue-on-error: true finish: + name: Finish Run needs: - test-preliminary - test-pypi - test-conda runs-on: ubuntu-latest - container: python:3-slim + permissions: + pull-requests: write steps: + - name: Harden Runner + uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + disable-sudo: true + egress-policy: audit - name: Start Energy Measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: start-measurement - branch: ${{ github.event.pull_request.head.ref }} + branch: ${{ github.head_ref || github.ref_name }} + continue-on-error: true - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: @@ -368,8 +413,11 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement - label: 'finish' + label: 'Finish Run' + continue-on-error: true - name: Show Energy Results uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results + pr-comment: true + continue-on-error: true From ea3992a61a0227c9c14035fe65a4867be6e139bc Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:32:33 -0400 Subject: [PATCH 07/48] allow sudo --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f33b61343..63628c810 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -216,7 +216,6 @@ jobs: if : ${{ matrix.os == 'ubuntu-latest' }} uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: - disable-sudo: true egress-policy: block allowed-endpoints: > api.electricitymap.org:443 From 93d4345ebf5f1b820e57e8ce4ad405e390f30c6b Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:33:25 -0400 Subject: [PATCH 08/48] add depedency review --- .github/workflows/dependency-review.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index f7814b0cc..088eac6d6 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -25,8 +25,22 @@ jobs: api.github.com:443 github.com:443 + - name: Start Energy Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: start-measurement + branch: ${{ github.head_ref || github.ref_name }} + - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Dependency Review uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 + + - name: Energy Measurement + if : ${{ matrix.os == 'ubuntu-latest' }} + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: get-measurement + label: 'Dependency Review' + continue-on-error: true From 7a992f0095b2f765e38f9e3434994821c95c6bc2 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:49:49 -0400 Subject: [PATCH 09/48] wip - audit --- .github/workflows/dependency-review.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 088eac6d6..67e8ac49b 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -18,12 +18,7 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 with: - disable-sudo: true - egress-policy: block - allowed-endpoints: > - api.deps.dev:443 - api.github.com:443 - github.com:443 + egress-policy: audit - name: Start Energy Measurement uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 From 23f5981f725432616937d13d4208c32b11d3b29d Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:27:22 -0400 Subject: [PATCH 10/48] fix commenting --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 63628c810..825fe34c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -375,7 +375,7 @@ jobs: continue-on-error: true finish: - name: Finish Run + name: Finish needs: - test-preliminary - test-pypi @@ -418,5 +418,4 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: display-results - pr-comment: true continue-on-error: true From 38f5b4a37f79d3028c281d26115fa2fd72b7bcaa Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Mon, 5 Aug 2024 15:49:47 -0400 Subject: [PATCH 11/48] wip - fix reporting --- .github/workflows/dependency-review.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 67e8ac49b..8d0dd1a9c 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -33,9 +33,14 @@ jobs: uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 - name: Energy Measurement - if : ${{ matrix.os == 'ubuntu-latest' }} uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 with: task: get-measurement label: 'Dependency Review' continue-on-error: true + + - name: Show Energy Results + uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + with: + task: display-results + continue-on-error: true From ef8d010b8cae1cfaf44276293b93e04279455a7e Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:13:09 -0400 Subject: [PATCH 12/48] wip - try testing branch --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 825fe34c1..961ec8189 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -233,7 +233,7 @@ jobs: sum.golang.org:443 - name: Start Energy Measurement if : ${{ matrix.os == 'ubuntu-latest' }} - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -254,7 +254,7 @@ jobs: python -m pip install --require-hashes -r CI/requirements_ci.txt - name: Environment Setup Energy Measurement if : ${{ matrix.os == 'ubuntu-latest' }} - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Environment setup (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})' @@ -277,14 +277,14 @@ jobs: COVERALLS_PARALLEL: true - name: Tests measurement if : ${{ matrix.os == 'ubuntu-latest' }} - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Testing with tox (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})' continue-on-error: true - name: Show Energy Results if : ${{ matrix.os == 'ubuntu-latest' }} - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: display-results continue-on-error: true From f8a08fa1aec6f47c24391b3b1ab67e7feea15493 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:25:45 -0400 Subject: [PATCH 13/48] wip - use testing branch --- .github/workflows/dependency-review.yml | 6 ++--- .github/workflows/main.yml | 30 ++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 8d0dd1a9c..095f78d9f 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -21,7 +21,7 @@ jobs: egress-policy: audit - name: Start Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -33,14 +33,14 @@ jobs: uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 - name: Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Dependency Review' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: display-results continue-on-error: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 961ec8189..9bb57beb4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,7 +59,7 @@ jobs: pypi.org:443 sum.golang.org:443 - name: Start Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -74,7 +74,7 @@ jobs: run: | python -m pip install --require-hashes -r CI/requirements_ci.txt - name: Setup Python Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Environment setup (Python${{ matrix.python-version }}, lint)' @@ -86,13 +86,13 @@ jobs: run: | python -m tox -e lint - name: Tests measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Lint (Python${{ matrix.python-version }})' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: display-results continue-on-error: true @@ -124,7 +124,7 @@ jobs: raw.githubusercontent.com:443 sum.golang.org:443 - name: Start Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -139,7 +139,7 @@ jobs: run: | python -m pip install --require-hashes -r CI/requirements_ci.txt - name: Environment Setup Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Environment setup (Python${{ matrix.python-version }}, standard)' @@ -152,13 +152,13 @@ jobs: COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.tox-env }} COVERALLS_PARALLEL: true - name: Tests measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Testing with tox (Python${{ matrix.python-version }})' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: display-results continue-on-error: true @@ -323,7 +323,7 @@ jobs: raw.githubusercontent.com:443 sum.golang.org:443 - name: Start Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -347,7 +347,7 @@ jobs: xclim show_version_info python -m pip check || true - name: Environment Setup Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Environment setup (conda, Python${{ matrix.python-version }})' @@ -363,13 +363,13 @@ jobs: COVERALLS_FLAG_NAME: run-{{ matrix.python-version }}-conda COVERALLS_PARALLEL: true - name: Tests measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Testing with pytest (conda, Python${{ matrix.python-version }})' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: display-results continue-on-error: true @@ -390,7 +390,7 @@ jobs: disable-sudo: true egress-policy: audit - name: Start Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -409,13 +409,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Finish measurement - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: get-measurement label: 'Finish Run' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@7333e9a8e8036e5bf69d59dc8bb63d984b0f55c8 # v3.1 + uses: green-coding-solutions/eco-ci-energy-estimation@escape-test with: task: display-results continue-on-error: true From 5cd24cdb6f8461d451d1402db92da6d13e008595 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:02:06 -0400 Subject: [PATCH 14/48] update allowlist --- .github/workflows/dependency-review.yml | 15 ++++++++++++++- .github/workflows/main.yml | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 095f78d9f..fe066bd71 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -18,7 +18,20 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 with: - egress-policy: audit + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.deps.dev:443 + api.electricitymap.org:443 + api.github.com:443 + api.green-coding.io:443 + api.securityscorecards.dev:443 + github.com:443 + ip-api.com:80 + ipapi.co:443 + proxy.golang.org:443 + pypi.org:443 + sum.golang.org:443 - name: Start Energy Measurement uses: green-coding-solutions/eco-ci-energy-estimation@escape-test diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9bb57beb4..45ad8868a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,6 +55,7 @@ jobs: files.pythonhosted.org:443 github.com:443 ip-api.com:80 + ipapi.co:443 proxy.golang.org:443 pypi.org:443 sum.golang.org:443 @@ -119,6 +120,7 @@ jobs: files.pythonhosted.org:443 github.com:443 ip-api.com:80 + ipapi.co:443 proxy.golang.org:443 pypi.org:443 raw.githubusercontent.com:443 @@ -226,6 +228,7 @@ jobs: files.pythonhosted.org:443 github.com:443 ip-api.com:80 + ipapi.co:443 motd.ubuntu.com:443 proxy.golang.org:443 pypi.org:443 @@ -317,6 +320,7 @@ jobs: files.pythonhosted.org:443 github.com:443 ip-api.com:80 + ipapi.co:443 objects.githubusercontent.com:443 proxy.golang.org:443 pypi.org:443 From 11282d7e3d2e549642defb390d042ad386d4cb0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:38:17 +0000 Subject: [PATCH 15/48] Bump the python group with 2 updates Bumps the python group with 2 updates: [packaging](https://github.com/pypa/packaging) and [deptry](https://github.com/fpgmaas/deptry). Updates `packaging` from 24.1 to 24.2 - [Release notes](https://github.com/pypa/packaging/releases) - [Changelog](https://github.com/pypa/packaging/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pypa/packaging/compare/24.1...24.2) Updates `deptry` from 0.20.0 to 0.21.0 - [Release notes](https://github.com/fpgmaas/deptry/releases) - [Changelog](https://github.com/fpgmaas/deptry/blob/main/CHANGELOG.md) - [Commits](https://github.com/fpgmaas/deptry/compare/0.20.0...0.21.0) --- updated-dependencies: - dependency-name: packaging dependency-type: direct:production update-type: version-update:semver-minor dependency-group: python - dependency-name: deptry dependency-type: direct:production update-type: version-update:semver-minor dependency-group: python ... Signed-off-by: dependabot[bot] --- CI/requirements_ci.in | 2 +- CI/requirements_ci.txt | 6 +++--- pyproject.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CI/requirements_ci.in b/CI/requirements_ci.in index dbff75495..b95fdf60e 100644 --- a/CI/requirements_ci.in +++ b/CI/requirements_ci.in @@ -1,5 +1,5 @@ bump-my-version==0.28.1 -deptry==0.20.0 +deptry==0.21.0 flit==3.10.1 pip==24.3.1 pylint==3.3.1 diff --git a/CI/requirements_ci.txt b/CI/requirements_ci.txt index 14c8334ea..554869500 100644 --- a/CI/requirements_ci.txt +++ b/CI/requirements_ci.txt @@ -195,9 +195,9 @@ mdurl==0.1.2 \ --hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8 \ --hash=sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba # via markdown-it-py -packaging==24.1 \ - --hash=sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002 \ - --hash=sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124 +packaging==24.2 \ + --hash=sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759 \ + --hash=sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f # via # pyproject-api # tox diff --git a/pyproject.toml b/pyproject.toml index 082108e7a..8a59b68ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ dev = [ "codespell ==2.3.0", "coverage[toml] >=7.5.0", "coveralls >=4.0.1", # coveralls is not yet compatible with Python 3.13 - "deptry ==0.20.0", + "deptry ==0.21.0", "flake8 >=7.1.1", "flake8-rst-docstrings >=0.3.0", "h5netcdf>=1.3.0", From d7ec02474d63b5324bbca8c93a8f1640778e1244 Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Mon, 11 Nov 2024 17:21:10 -0500 Subject: [PATCH 16/48] Fix wrong unpickling with dask 2024.11 --- CHANGELOG.rst | 6 +++++- environment.yml | 2 +- pyproject.toml | 2 +- xclim/sdba/base.py | 18 +++++++++--------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0f2da06ec..e1fca65e7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,12 +4,16 @@ Changelog v0.54.0 (unreleased) -------------------- -Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), +Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`). Breaking changes ---------------- * The minimum required version of `dask` has been increased to `2024.8.1`. `dask` versions at or above `2024.11` are not yet supported. (:issue:`1992`, :pull:`1991`). +Bug fixes +^^^^^^^^^ +* Fixes ``xclim.sdba.Grouper`` and other classes for usage with dask 2024.11 (:issue:`1992`, :pull:`1993`). + v0.53.2 (2024-10-31) -------------------- Contributors to this version: Éric Dupuis (:user:`coxipi`), Pascal Bourgault (:user:`aulemahal`), Trevor James Smith (:user:`Zeitsperre`). diff --git a/environment.yml b/environment.yml index 7a5f08ad9..88f13bce9 100644 --- a/environment.yml +++ b/environment.yml @@ -9,7 +9,7 @@ dependencies: - cf_xarray >=0.9.3 - cftime >=1.4.1 - click >=8.1 - - dask >=2024.8.1,<2024.11.0 + - dask >=2024.8.1 - filelock >=3.14.0 - jsonpickle >=3.1.0 - numba >=0.54.1 diff --git a/pyproject.toml b/pyproject.toml index 5ab0d9c3e..c6bb2592a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ dependencies = [ "cf-xarray >=0.9.3", # cf-xarray is differently named on conda-forge "cftime >=1.4.1", "click >=8.1", - "dask[array] >=2024.8.1,<2024.11.0", + "dask[array] >=2024.8.1", "filelock >=3.14.0", "jsonpickle >=3.1.0", "numba >=0.54.1", diff --git a/xclim/sdba/base.py b/xclim/sdba/base.py index 5036058ef..03ec7d091 100644 --- a/xclim/sdba/base.py +++ b/xclim/sdba/base.py @@ -5,6 +5,7 @@ from __future__ import annotations +from collections import UserDict from collections.abc import Callable, Sequence from inspect import _empty, signature # noqa @@ -20,7 +21,7 @@ # ## Base class for the sdba module -class Parametrizable(dict): +class Parametrizable(UserDict): """Helper base class resembling a dictionary. This object is _completely_ defined by the content of its internal dictionary, accessible through item access @@ -35,24 +36,23 @@ class Parametrizable(dict): def __getstate__(self): """For (json)pickle, a Parametrizable should be defined by its internal dict only.""" - return self.parameters + return self.data def __setstate__(self, state): """For (json)pickle, a Parametrizable in only defined by its internal dict.""" - self.update(state) + # Unpickling skips the init, so we must _set_ data, we can't just update it - it's not there yet + self.data = {**state} def __getattr__(self, attr): """Get attributes.""" - try: - return self.__getitem__(attr) - except KeyError as err: - # Raise the proper error type for getattr - raise AttributeError(*err.args) from err + if attr == "data" or attr not in self.data: + return self.__getattribute__(attr) + return self.data[attr] @property def parameters(self) -> dict: """All parameters as a dictionary. Read-only.""" - return {**self} + return {**self.data} def __repr__(self) -> str: """Return a string representation.""" From 478c6be89c192292ca402b2db245a6fea1b2ca82 Mon Sep 17 00:00:00 2001 From: David Huard Date: Tue, 12 Nov 2024 11:35:43 -0500 Subject: [PATCH 17/48] =?UTF-8?q?Changed=20french=20translations=20with=20?= =?UTF-8?q?word=20"pluvieux"=20to=20"avec=20pr=C3=A9cipitations".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.rst | 5 +++++ xclim/data/fr.json | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0f2da06ec..51da862f1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,11 @@ Breaking changes ---------------- * The minimum required version of `dask` has been increased to `2024.8.1`. `dask` versions at or above `2024.11` are not yet supported. (:issue:`1992`, :pull:`1991`). +Internal changes +^^^^^^^^^^^^^^^^ +* Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`). + + v0.53.2 (2024-10-31) -------------------- Contributors to this version: Éric Dupuis (:user:`coxipi`), Pascal Bourgault (:user:`aulemahal`), Trevor James Smith (:user:`Zeitsperre`). diff --git a/xclim/data/fr.json b/xclim/data/fr.json index 94822e704..d42c6b437 100644 --- a/xclim/data/fr.json +++ b/xclim/data/fr.json @@ -206,7 +206,7 @@ "WETDAYS": { "long_name": "Nombre de jours où la précipitation est supérieure ou égale à {thresh}", "description": "Nombre {freq:m} de jours où la précipitation est supérieure ou égale à {thresh}.", - "title": "Jours pluvieux", + "title": "Jours avec précipitations", "abstract": "Nombre de jours où la précipitation est supérieure ou égale à un seuil donné." }, "WETDAYS_PROP": { @@ -224,7 +224,7 @@ "CWD": { "long_name": "Durée maximale d'une période où les précipitations sont au-dessus de {thresh}", "description": "Nombre {freq:m} maximal de jours consécutifs où les précipitations sont au-dessus de {thresh}.", - "title": "Durée de période pluvieuse", + "title": "Durée de la période de précipitation", "abstract": "Période la plus longue où la précipitation est au-dessus d'un seuil donné." }, "SDII": { @@ -1300,13 +1300,13 @@ "WARM_AND_WET_DAYS": { "long_name": "Nombre de jours où la température est au-dessus du {tas_per_thresh}e centile et la précipitation au-dessus du {pr_per_thresh}e centile", "description": "Nombre {freq:m} de jours où la température est au-dessus du {tas_per_thresh}e centile et la précipitation au-dessus du {pr_per_thresh}e centile.", - "title": "Nombre de jours chauds et pluvieux", + "title": "Nombre de jours chauds avec précipitations", "abstract": "Nombre de jours où la température et la précipitation sont au-dessus de centiles donnés." }, "COLD_AND_WET_DAYS": { "long_name": "Nombre de jours où la température est en dessous du {tas_per_thresh}e centile et la précipitation au-dessus du {pr_per_thresh}e centile", "description": "Nombre {freq:m} de jours où la température est en dessous du {tas_per_thresh}e centile et la précipitation au-dessus du {pr_per_thresh}e centile.", - "title": "Nombre de jours froids et pluvieux", + "title": "Nombre de jours froids avec précipitations", "abstract": "Nombre de jours où la température est en dessous d'un centile donné et la précipitation au-dessus d'un centile donné." }, "CALM_DAYS": { From 5e99d170d46c1df4f9d25c77a87c21fda57f5a06 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:42:05 -0500 Subject: [PATCH 18/48] Update CHANGELOG.rst --- CHANGELOG.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 51da862f1..6b4d4b9cb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,7 +14,6 @@ Internal changes ^^^^^^^^^^^^^^^^ * Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`). - v0.53.2 (2024-10-31) -------------------- Contributors to this version: Éric Dupuis (:user:`coxipi`), Pascal Bourgault (:user:`aulemahal`), Trevor James Smith (:user:`Zeitsperre`). From 446dc3ff686fca0b345965e14e3655985f4e4fb9 Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Tue, 12 Nov 2024 11:48:59 -0500 Subject: [PATCH 19/48] Apply suggestions from code review Co-authored-by: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> --- CHANGELOG.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e1fca65e7..e00a7567d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,11 +8,11 @@ Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bo Breaking changes ---------------- -* The minimum required version of `dask` has been increased to `2024.8.1`. `dask` versions at or above `2024.11` are not yet supported. (:issue:`1992`, :pull:`1991`). +* The minimum required version of `dask` has been increased to `2024.8.1`. (:issue:`1992`, :pull:`1991`). Bug fixes ^^^^^^^^^ -* Fixes ``xclim.sdba.Grouper`` and other classes for usage with dask 2024.11 (:issue:`1992`, :pull:`1993`). +* Fixed pickling issue with ``xclim.sdba.Grouper`` and other classes for usage with `dask>=2024.11`. (:issue:`1992`, :pull:`1993`). v0.53.2 (2024-10-31) -------------------- From a3c1df74a3da0e9a061ccb596bb90c16ece99803 Mon Sep 17 00:00:00 2001 From: Ouranos Helper Bot Date: Tue, 12 Nov 2024 18:07:32 +0000 Subject: [PATCH 20/48] =?UTF-8?q?Bump=20version:=200.53.2=20=E2=86=92=200.?= =?UTF-8?q?53.3-dev.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- xclim/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f79dcb8f2..c1c10f6d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,7 +134,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.53.2" +current_version = "0.53.3-dev.0" commit = true commit_args = "--no-verify" tag = false diff --git a/xclim/__init__.py b/xclim/__init__.py index 2680845d2..c6bb279b2 100644 --- a/xclim/__init__.py +++ b/xclim/__init__.py @@ -13,7 +13,7 @@ __author__ = """Travis Logan""" __email__ = "logan.travis@ouranos.ca" -__version__ = "0.53.2" +__version__ = "0.53.3-dev.0" with _resources.as_file(_resources.files("xclim.data")) as _module_data: From e928777d9e2735591f7eed502c029998c0e3fc53 Mon Sep 17 00:00:00 2001 From: Ouranos Helper Bot Date: Tue, 12 Nov 2024 19:16:33 +0000 Subject: [PATCH 21/48] =?UTF-8?q?Bump=20version:=200.53.3-dev.0=20?= =?UTF-8?q?=E2=86=92=200.53.3-dev.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- xclim/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 50940c858..1290119f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,7 +134,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.53.3-dev.0" +current_version = "0.53.3-dev.1" commit = true commit_args = "--no-verify" tag = false diff --git a/xclim/__init__.py b/xclim/__init__.py index c6bb279b2..f9468bfe2 100644 --- a/xclim/__init__.py +++ b/xclim/__init__.py @@ -13,7 +13,7 @@ __author__ = """Travis Logan""" __email__ = "logan.travis@ouranos.ca" -__version__ = "0.53.3-dev.0" +__version__ = "0.53.3-dev.1" with _resources.as_file(_resources.files("xclim.data")) as _module_data: From 68212db032f6bab2dc04738e114fa0257566f8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Wed, 13 Nov 2024 13:37:33 -0500 Subject: [PATCH 22/48] streamflow uses `strf` instead of `q` --- CHANGELOG.rst | 3 +- tests/conftest.py | 8 ++-- tests/test_generic.py | 28 +++++++------- tests/test_generic_indicators.py | 35 +++++++++-------- tests/test_hydrology.py | 20 +++++----- tests/test_land.py | 26 ++++++------- tests/test_stats.py | 8 ++-- xclim/core/indicator.py | 2 +- xclim/data/fr.json | 4 +- xclim/data/variables.yml | 2 +- xclim/indicators/land/_streamflow.py | 24 ++++++------ xclim/indices/_hydrology.py | 56 ++++++++++++++-------------- 12 files changed, 111 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f85d72b51..d0f183b60 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,7 +4,7 @@ Changelog v0.54.0 (unreleased) -------------------- -Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`). +Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`), Éric Dupuis (:user:`coxipi`). Breaking changes ---------------- @@ -17,6 +17,7 @@ Bug fixes Internal changes ^^^^^^^^^^^^^^^^ * Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`). +* Streamflow variables now expressed as `strf` instead of `q`, with a proper entry in ``variables.yml`` (:issue:`1912`, :pull:``) v0.53.2 (2024-10-31) -------------------- diff --git a/tests/conftest.py b/tests/conftest.py index ba3597b17..ca245e0b1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -140,8 +140,8 @@ def _pr_series(values, start="1/1/2000", units="kg m-2 s-1"): @pytest.fixture -def q_series(): - def _q_series(values, start="1/1/2000", units="m3 s-1"): +def strf_series(): + def _strf_series(values, start="1/1/2000", units="m3 s-1"): coords = pd.date_range(start, periods=len(values), freq="D") return xr.DataArray( values, @@ -154,11 +154,11 @@ def _q_series(values, start="1/1/2000", units="m3 s-1"): }, ) - return _q_series + return _strf_series @pytest.fixture -def ndq_series(random): +def ndstrf_series(random): nx, ny, nt = 2, 3, 5000 x = np.arange(0, nx) y = np.arange(0, ny) diff --git a/tests/test_generic.py b/tests/test_generic.py index 8191624a9..d95972bcc 100644 --- a/tests/test_generic.py +++ b/tests/test_generic.py @@ -14,27 +14,27 @@ class TestSelectResampleOp: - def test_month(self, q_series): - q = q_series(np.arange(1000)) + def test_month(self, strf_series): + q = strf_series(np.arange(1000)) o = generic.select_resample_op(q, "count", freq="YS", month=3) np.testing.assert_array_equal(o, 31) - def test_season_default(self, q_series): + def test_season_default(self, strf_series): # Will use freq='YS', so count J, F and D of each year. - q = q_series(np.arange(1000)) + q = strf_series(np.arange(1000)) o = generic.select_resample_op(q, "min", season="DJF") assert o[0] == 0 assert o[1] == 366 - def test_season(self, q_series): - q = q_series(np.arange(1000)) + def test_season(self, strf_series): + q = strf_series(np.arange(1000)) o = generic.select_resample_op(q, "count", freq="YS-DEC", season="DJF") assert o[0] == 31 + 29 class TestSelectRollingResampleOp: - def test_rollingmax(self, q_series): - q = q_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap + def test_rollingmax(self, strf_series): + q = strf_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap o = generic.select_rolling_resample_op( q, "max", window=14, window_center=False, window_op="mean" ) @@ -48,8 +48,8 @@ def test_rollingmax(self, q_series): ) assert o.attrs["units"] == "m3 s-1" - def test_rollingmaxindexer(self, q_series): - q = q_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap + def test_rollingmaxindexer(self, strf_series): + q = strf_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap o = generic.select_rolling_resample_op( q, "min", window=14, window_center=False, window_op="max", season="DJF" ) @@ -58,8 +58,8 @@ def test_rollingmaxindexer(self, q_series): ) # 14th day for 1st year, then Jan 1st for the next two assert o.attrs["units"] == "m3 s-1" - def test_freq(self, q_series): - q = q_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap + def test_freq(self, strf_series): + q = strf_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap o = generic.select_rolling_resample_op( q, "max", window=3, window_center=True, window_op="integral", freq="MS" ) @@ -88,13 +88,13 @@ def test_simple(self, tas_series): class TestFlowGeneric: - def test_doyminmax(self, q_series): + def test_doyminmax(self, strf_series): a = np.ones(365) a[9] = 2 a[19] = -2 a[39] = 4 a[49] = -4 - q = q_series(a) + q = strf_series(a) dmx = generic.doymax(q) dmn = generic.doymin(q) assert dmx.values == [40] diff --git a/tests/test_generic_indicators.py b/tests/test_generic_indicators.py index 6411e1479..427e2326c 100644 --- a/tests/test_generic_indicators.py +++ b/tests/test_generic_indicators.py @@ -31,8 +31,8 @@ def test_ndim(self, pr_ndseries, random): assert out.shape == (2, 1, 2) np.testing.assert_array_equal(out.isnull(), False) - def test_options(self, q_series, random): - q = q_series(random.random(19)) + def test_options(self, strf_series, random): + q = strf_series(random.random(19)) out = generic.fit(q, dist="norm") np.testing.assert_array_equal(out.isnull(), False) @@ -42,9 +42,9 @@ def test_options(self, q_series, random): class TestReturnLevel: - def test_seasonal(self, ndq_series): + def test_seasonal(self, ndstrf_series): out = generic.return_level( - ndq_series, mode="max", t=[2, 5], dist="gamma", season="DJF" + ndstrf_series, mode="max", t=[2, 5], dist="gamma", season="DJF" ) assert out.description == ( @@ -60,8 +60,8 @@ def test_any_variable(self, pr_series, random): out = generic.return_level(pr, mode="max", t=2, dist="gamma") assert out.units == pr.units - def test_no_indexer(self, ndq_series): - out = generic.return_level(ndq_series, mode="max", t=[2, 5], dist="gamma") + def test_no_indexer(self, ndstrf_series): + out = generic.return_level(ndstrf_series, mode="max", t=[2, 5], dist="gamma") assert out.description in [ "Frequency analysis for the maximal annual 1-day value estimated using the gamma distribution." ] @@ -69,12 +69,14 @@ def test_no_indexer(self, ndq_series): assert out.shape == (2, 2, 3) # nrt, nx, ny np.testing.assert_array_equal(out.isnull(), False) - def test_q27(self, ndq_series): - out = generic.return_level(ndq_series, mode="max", t=2, dist="gamma", window=7) + def test_q27(self, ndstrf_series): + out = generic.return_level( + ndstrf_series, mode="max", t=2, dist="gamma", window=7 + ) assert out.shape == (1, 2, 3) - def test_empty(self, ndq_series): - q = ndq_series.copy() + def test_empty(self, ndstrf_series): + q = ndstrf_series.copy() q[:, 0, 0] = np.nan out = generic.return_level( q, mode="max", t=2, dist="genextreme", window=6, freq="YS" @@ -94,13 +96,16 @@ def test_simple(self, pr_series, random, op, word): out = generic.stats(pr, freq="YS", op=op) assert out.long_name == f"{word} of variable" - def test_ndq(self, ndq_series): - out = generic.stats(ndq_series, freq="YS", op="min", season="MAM") + def test_ndq(self, ndstrf_series): + out = generic.stats(ndstrf_series, freq="YS", op="min", season="MAM") assert out.attrs["units"] == "m3 s-1" - def test_missing(self, ndq_series): - a = ndq_series.where( - ~((ndq_series.time.dt.dayofyear == 5) & (ndq_series.time.dt.year == 1902)) + def test_missing(self, ndstrf_series): + a = ndstrf_series.where( + ~( + (ndstrf_series.time.dt.dayofyear == 5) + & (ndstrf_series.time.dt.year == 1902) + ) ) assert a.shape == (5000, 2, 3) out = generic.stats(a, op="max", month=1) diff --git a/tests/test_hydrology.py b/tests/test_hydrology.py index 0572d12e1..a7ae5fe4d 100644 --- a/tests/test_hydrology.py +++ b/tests/test_hydrology.py @@ -6,19 +6,19 @@ class TestBaseFlowIndex: - def test_simple(self, q_series): + def test_simple(self, strf_series): a = np.zeros(365) + 10 a[10:17] = 1 - q = q_series(a) + q = strf_series(a) out = xci.base_flow_index(q) np.testing.assert_array_equal(out, 1.0 / a.mean()) class TestRBIndex: - def test_simple(self, q_series): + def test_simple(self, strf_series): a = np.zeros(365) a[10] = 10 - q = q_series(a) + q = strf_series(a) out = xci.rb_flashiness_index(q) np.testing.assert_array_equal(out, 2) @@ -73,30 +73,30 @@ def test_simple(self, snw_series, pr_series): class TestFlowindex: - def test_simple(self, q_series): + def test_simple(self, strf_series): a = np.ones(365 * 2) * 10 a[10:50] = 50 - q = q_series(a) + q = strf_series(a) out = xci.flow_index(q, 0.95) np.testing.assert_array_equal(out, 5) class TestHighflowfrequency: - def test_simple(self, q_series): + def test_simple(self, strf_series): a = np.zeros(365 * 2) a[50:60] = 10 a[200:210] = 20 - q = q_series(a) + q = strf_series(a) out = xci.high_flow_frequency(q, 9, freq="YS") np.testing.assert_array_equal(out, [20, 0]) class TestLowflowfrequency: - def test_simple(self, q_series): + def test_simple(self, strf_series): a = np.ones(365 * 2) * 10 a[50:60] = 1 a[200:210] = 1 - q = q_series(a) + q = strf_series(a) out = xci.low_flow_frequency(q, 0.2, freq="YS") np.testing.assert_array_equal(out, [20, 0]) diff --git a/tests/test_land.py b/tests/test_land.py index aedc1563b..4af5c86ca 100644 --- a/tests/test_land.py +++ b/tests/test_land.py @@ -8,27 +8,27 @@ from xclim import land -def test_base_flow_index(ndq_series): - out = land.base_flow_index(ndq_series, freq="YS") +def test_base_flow_index(ndstrf_series): + out = land.base_flow_index(ndstrf_series, freq="YS") assert out.attrs["units"] == "1" assert isinstance(out, xr.DataArray) -def test_rb_flashiness_index(ndq_series): - out = land.base_flow_index(ndq_series, freq="YS") +def test_rb_flashiness_index(ndstrf_series): + out = land.base_flow_index(ndstrf_series, freq="YS") assert out.attrs["units"] == "1" assert isinstance(out, xr.DataArray) -def test_qdoy_max(ndq_series, q_series): - out = land.doy_qmax(ndq_series, freq="YS", season="JJA") +def test_qdoy_max(ndstrf_series, strf_series): + out = land.doy_strfmax(ndstrf_series, freq="YS", season="JJA") assert out.attrs["units"] == "1" a = np.ones(450) a[100] = 2 - out = land.doy_qmax(q_series(a), freq="YS") + out = land.doy_strfmax(strf_series(a), freq="YS") assert out[0] == 101 @@ -68,20 +68,20 @@ def test_snw_storm_days(snw_series): np.testing.assert_array_equal(out, [9, np.nan]) -def test_flow_index(q_series): +def test_flow_index(strf_series): a = np.ones(365 * 2) * 10 a[10:50] = 50 - q = q_series(a) + q = strf_series(a) out = land.flow_index(q, p=0.95) np.testing.assert_array_equal(out, 5) -def test_high_flow_frequency(q_series): +def test_high_flow_frequency(strf_series): a = np.zeros(366 * 2) * 10 a[50:60] = 10 a[200:210] = 20 - q = q_series(a) + q = strf_series(a) out = land.high_flow_frequency( q, threshold_factor=9, @@ -90,10 +90,10 @@ def test_high_flow_frequency(q_series): np.testing.assert_array_equal(out, [20, 0, np.nan]) -def test_low_flow_frequency(q_series): +def test_low_flow_frequency(strf_series): a = np.ones(366 * 2) * 10 a[50:60] = 1 a[200:210] = 1 - q = q_series(a) + q = strf_series(a) out = land.low_flow_frequency(q, threshold_factor=0.2, freq="YS") np.testing.assert_array_equal(out, [20, 0, np.nan]) diff --git a/tests/test_stats.py b/tests/test_stats.py index 29a40b3f0..ef41b5955 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -266,8 +266,8 @@ def test_pwm_fit(self, dist, use_dask, random): @pytest.mark.parametrize("use_dask", [True, False]) @pytest.mark.filterwarnings("ignore::RuntimeWarning") -def test_frequency_analysis(ndq_series, use_dask): - q = ndq_series.copy() +def test_frequency_analysis(ndstrf_series, use_dask): + q = ndstrf_series.copy() q[:, 0, 0] = np.nan if use_dask: q = q.chunk() @@ -291,9 +291,9 @@ def test_frequency_analysis(ndq_series, use_dask): @pytest.mark.parametrize("use_dask", [True, False]) @pytest.mark.filterwarnings("ignore::RuntimeWarning") -def test_frequency_analysis_lmoments(ndq_series, use_dask): +def test_frequency_analysis_lmoments(ndstrf_series, use_dask): lmom = pytest.importorskip("lmoments3.distr") - q = ndq_series.copy() + q = ndstrf_series.copy() q[:, 0, 0] = np.nan if use_dask: q = q.chunk() diff --git a/xclim/core/indicator.py b/xclim/core/indicator.py index 1822d04c4..02938058d 100644 --- a/xclim/core/indicator.py +++ b/xclim/core/indicator.py @@ -1205,7 +1205,7 @@ def json(cls, args=None): param["choices"] = list(param["choices"]) if param["default"] is _empty_default: del param["default"] - elif callable(param): # Rare special case (doy_qmax and doy_qmin). + elif callable(param): # Rare special case (doy_strfmax and doy_strfmin). out["parameters"][name] = f"{param.__module__}.{param.__name__}" return out diff --git a/xclim/data/fr.json b/xclim/data/fr.json index d42c6b437..84a81e531 100644 --- a/xclim/data/fr.json +++ b/xclim/data/fr.json @@ -716,13 +716,13 @@ "title": "Calcul les paramètres d'une distribution univariée pour un ensemble de données", "abstract": "" }, - "DOY_QMAX": { + "DOY_STRFMAX": { "long_name": "Jour de l'année du maximum du débit en {indexer:nom}", "description": "Jour de l'année du maximum du débit en {indexer:nom}.", "title": "Jour de l'année du maximum du débit", "abstract": "" }, - "DOY_QMIN": { + "DOY_STRFMIN": { "long_name": "Jour de l'année du minimum du débit en {indexer:nom}", "description": "Jour de l'année du minimum du débit en {indexer:nom}.", "title": "Jour de l'année du minimum du débit", diff --git a/xclim/data/variables.yml b/xclim/data/variables.yml index a02194514..29362380e 100644 --- a/xclim/data/variables.yml +++ b/xclim/data/variables.yml @@ -237,7 +237,7 @@ variables: standard_name: lwe_thickness_of_snow_amount data_flags: - negative_accumulation_values: - streamflow: + strf: canonical_units: m3 s-1 cell_methods: "time: mean" description: The amount of water, in all phases, flowing in the river channel and flood plain. diff --git a/xclim/indicators/land/_streamflow.py b/xclim/indicators/land/_streamflow.py index fc73699af..0e94b414b 100644 --- a/xclim/indicators/land/_streamflow.py +++ b/xclim/indicators/land/_streamflow.py @@ -19,8 +19,8 @@ __all__ = [ "base_flow_index", - "doy_qmax", - "doy_qmin", + "doy_strfmax", + "doy_strfmin", "flow_index", "high_flow_frequency", "low_flow_frequency", @@ -37,8 +37,8 @@ class Streamflow(ResamplingIndicator): # TODO: TJS: The signature of this method seems wrong. Should it be `def cfcheck(cls, q):` or something else? Is it a static method? @staticmethod - def cfcheck(q): - check_valid(q, "standard_name", "water_volume_transport_in_river_channel") + def cfcheck(strf): + check_valid(strf, "standard_name", "water_volume_transport_in_river_channel") base_flow_index = Streamflow( @@ -65,10 +65,10 @@ def cfcheck(q): ) -doy_qmax = Streamflow( +doy_strfmax = Streamflow( title="Day of year of the maximum streamflow", identifier="doy_qmax", - var_name="q{indexer}_doy_qmax", + var_name="strf{indexer}_doy_strfmax", long_name="Day of the year of the maximum streamflow over {indexer}", description="Day of the year of the maximum streamflow over {indexer}.", units="", @@ -77,10 +77,10 @@ def cfcheck(q): ) -doy_qmin = Streamflow( +doy_strfmin = Streamflow( title="Day of year of the minimum streamflow", - identifier="doy_qmin", - var_name="q{indexer}_doy_qmin", + identifier="doy_strfmin", + var_name="strf{indexer}_doy_strfmin", long_name="Day of the year of the minimum streamflow over {indexer}", description="Day of the year of the minimum streamflow over {indexer}.", units="", @@ -93,7 +93,7 @@ def cfcheck(q): context="hydro", title="Flow index", identifier="flow_index", - var_name="q_flow_index", + var_name="strf_flow_index", long_name="Flow index", description="{p}th percentile normalized by the median flow.", units="1", @@ -104,7 +104,7 @@ def cfcheck(q): high_flow_frequency = Streamflow( title="High flow frequency", identifier="high_flow_frequency", - var_name="q_high_flow_frequency", + var_name="strf_high_flow_frequency", long_name="High flow frequency", description="{freq} frequency of flows greater than {threshold_factor} times the median flow.", units="days", @@ -115,7 +115,7 @@ def cfcheck(q): low_flow_frequency = Streamflow( title="Low flow frequency", identifier="low_flow_frequency", - var_name="q_low_flow_frequency", + var_name="strf_low_flow_frequency", long_name="Low flow frequency", description="{freq} frequency of flows smaller than a fraction ({threshold_factor}) of the mean flow.", units="days", diff --git a/xclim/indices/_hydrology.py b/xclim/indices/_hydrology.py index 23d320cbc..0781b524e 100644 --- a/xclim/indices/_hydrology.py +++ b/xclim/indices/_hydrology.py @@ -26,15 +26,15 @@ ] -@declare_units(q="[discharge]") -def base_flow_index(q: xr.DataArray, freq: str = "YS") -> xr.DataArray: +@declare_units(strf="[discharge]") +def base_flow_index(strf: xr.DataArray, freq: str = "YS") -> xr.DataArray: r"""Base flow index. Return the base flow index, defined as the minimum 7-day average flow divided by the mean flow. Parameters ---------- - q : xarray.DataArray + strf : xarray.DataArray Rate of river discharge. freq : str Resampling frequency. @@ -61,8 +61,8 @@ def base_flow_index(q: xr.DataArray, freq: str = "YS") -> xr.DataArray: \mathrm{CMA}_7(q_i) = \frac{\sum_{j=i-3}^{i+3} q_j}{7} """ - m7 = q.rolling(time=7, center=True).mean(skipna=False).resample(time=freq) - mq = q.resample(time=freq) + m7 = strf.rolling(time=7, center=True).mean(skipna=False).resample(time=freq) + mq = strf.resample(time=freq) m7m = m7.min(dim="time") out = m7m / mq.mean(dim="time") @@ -70,8 +70,8 @@ def base_flow_index(q: xr.DataArray, freq: str = "YS") -> xr.DataArray: return out -@declare_units(q="[discharge]") -def rb_flashiness_index(q: xr.DataArray, freq: str = "YS") -> xr.DataArray: +@declare_units(strf="[discharge]") +def rb_flashiness_index(strf: xr.DataArray, freq: str = "YS") -> xr.DataArray: r"""Richards-Baker flashiness index. Measures oscillations in flow relative to total flow, quantifying the frequency and rapidity of short term changes @@ -79,7 +79,7 @@ def rb_flashiness_index(q: xr.DataArray, freq: str = "YS") -> xr.DataArray: Parameters ---------- - q : xarray.DataArray + strf : xarray.DataArray Rate of river discharge. freq : str Resampling frequency. @@ -101,8 +101,8 @@ def rb_flashiness_index(q: xr.DataArray, freq: str = "YS") -> xr.DataArray: ---------- :cite:cts:`baker_new_2004` """ - d = np.abs(q.diff(dim="time")).resample(time=freq) - mq = q.resample(time=freq) + d = np.abs(strf.diff(dim="time")).resample(time=freq) + mq = strf.resample(time=freq) out = d.sum(dim="time") / mq.sum(dim="time") out.attrs["units"] = "" return out @@ -285,8 +285,8 @@ def melt_and_precip_max( return out -@declare_units(q="[discharge]") -def flow_index(q: xr.DataArray, p: float = 0.95) -> xr.DataArray: +@declare_units(strf="[discharge]") +def flow_index(strf: xr.DataArray, p: float = 0.95) -> xr.DataArray: """ Flow index @@ -294,7 +294,7 @@ def flow_index(q: xr.DataArray, p: float = 0.95) -> xr.DataArray: Parameters ---------- - q : xr.DataArray + strf : xr.DataArray Daily streamflow data. p : float Percentile for calculating the flow index, between 0 and 1. Default of 0.95 is for high flows. @@ -308,16 +308,16 @@ def flow_index(q: xr.DataArray, p: float = 0.95) -> xr.DataArray: ---------- :cite:cts:`Clausen2000` """ - qp = q.quantile(p, dim="time") - q_median = q.median(dim="time") - out = qp / q_median + strfp = strf.quantile(p, dim="time") + strf_median = strf.median(dim="time") + out = strfp / strf_median out.attrs["units"] = "1" return out -@declare_units(q="[discharge]") +@declare_units(strf="[discharge]") def high_flow_frequency( - q: xr.DataArray, threshold_factor: int = 9, freq: str = "YS-OCT" + strf: xr.DataArray, threshold_factor: int = 9, freq: str = "YS-OCT" ) -> xr.DataArray: """ High flow frequency. @@ -328,7 +328,7 @@ def high_flow_frequency( Parameters ---------- - q : xr.DataArray + strf : xr.DataArray Daily streamflow data. threshold_factor : int Factor by which the median flow is multiplied to set the high flow threshold, default is 9. @@ -344,15 +344,15 @@ def high_flow_frequency( ---------- :cite:cts:`addor2018,Clausen2000` """ - median_flow = q.median(dim="time") + median_flow = strf.median(dim="time") threshold = threshold_factor * median_flow - out = threshold_count(q, ">", threshold, freq=freq) - return to_agg_units(out, q, "count") + out = threshold_count(strf, ">", threshold, freq=freq) + return to_agg_units(out, strf, "count") -@declare_units(q="[discharge]") +@declare_units(strf="[discharge]") def low_flow_frequency( - q: xr.DataArray, threshold_factor: float = 0.2, freq: str = "YS-OCT" + strf: xr.DataArray, threshold_factor: float = 0.2, freq: str = "YS-OCT" ) -> xr.DataArray: """ Low flow frequency. @@ -363,7 +363,7 @@ def low_flow_frequency( Parameters ---------- - q : xr.DataArray + strf : xr.DataArray Daily streamflow data. threshold_factor : float Factor by which the mean flow is multiplied to set the low flow threshold, default is 0.2. @@ -379,7 +379,7 @@ def low_flow_frequency( ---------- :cite:cts:`Olden2003` """ - mean_flow = q.mean(dim="time") + mean_flow = strf.mean(dim="time") threshold = threshold_factor * mean_flow - out = threshold_count(q, "<", threshold, freq=freq) - return to_agg_units(out, q, "count") + out = threshold_count(strf, "<", threshold, freq=freq) + return to_agg_units(out, strf, "count") From b768233aa3623cbb27670e5e6be5d7e57651822c Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:46:15 -0500 Subject: [PATCH 23/48] update energy measurement action version to latest --- .github/workflows/main.yml | 38 ++++++++++++++++----------------- .github/workflows/scorecard.yml | 8 +++---- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7bbaa6ab7..c9dc334f6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,7 +56,7 @@ jobs: pypi.org:443 sum.golang.org:443 - name: Start Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -72,7 +72,7 @@ jobs: run: | python -m pip install --require-hashes -r CI/requirements_ci.txt - name: Setup Python Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Environment setup (Python${{ matrix.python-version }}, lint)' @@ -91,13 +91,13 @@ jobs: run: | python -m tox -e lint - name: Tests measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Lint (Python${{ matrix.python-version }})' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: display-results continue-on-error: true @@ -131,7 +131,7 @@ jobs: raw.githubusercontent.com:443 sum.golang.org:443 - name: Start Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -147,7 +147,7 @@ jobs: run: | python -m pip install --require-hashes -r CI/requirements_ci.txt - name: Environment Setup Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Environment setup (Python${{ matrix.python-version }}, standard)' @@ -167,13 +167,13 @@ jobs: COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-ubuntu-latest-preliminary COVERALLS_PARALLEL: true - name: Tests measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Testing with tox (Python${{ matrix.python-version }})' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: display-results continue-on-error: true @@ -256,7 +256,7 @@ jobs: sum.golang.org:443 - name: Start Energy Measurement if : ${{ matrix.os == 'ubuntu-latest' }} - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -278,7 +278,7 @@ jobs: python -m pip install --require-hashes -r CI/requirements_ci.txt - name: Environment Setup Energy Measurement if : ${{ matrix.os == 'ubuntu-latest' }} - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Environment setup (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})' @@ -310,14 +310,14 @@ jobs: COVERALLS_PARALLEL: true - name: Tests measurement if : ${{ matrix.os == 'ubuntu-latest' }} - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Testing with tox (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})' continue-on-error: true - name: Show Energy Results if : ${{ matrix.os == 'ubuntu-latest' }} - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: display-results continue-on-error: true @@ -359,7 +359,7 @@ jobs: raw.githubusercontent.com:443 sum.golang.org:443 - name: Start Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -389,7 +389,7 @@ jobs: xclim show_version_info python -m pip check || true - name: Environment Setup Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Environment setup (conda, Python${{ matrix.python-version }})' @@ -405,13 +405,13 @@ jobs: COVERALLS_FLAG_NAME: run-{{ matrix.python-version }}-conda COVERALLS_PARALLEL: true - name: Tests measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Testing with pytest (conda, Python${{ matrix.python-version }})' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: display-results continue-on-error: true @@ -430,7 +430,7 @@ jobs: disable-sudo: true egress-policy: audit - name: Start Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -440,13 +440,13 @@ jobs: with: parallel-finished: true - name: Finish measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Finish Run' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: display-results continue-on-error: true diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 7965189a8..8477d39b1 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -35,12 +35,12 @@ jobs: egress-policy: audit - name: Checkout Repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: Run Analysis - uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 with: results_file: results.sarif results_format: sarif @@ -59,7 +59,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: Upload Artifact - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: SARIF file path: results.sarif @@ -67,6 +67,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: Upload to code-scanning - uses: github/codeql-action/upload-sarif@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # 3.23.0 + uses: github/codeql-action/upload-sarif@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # 3.23.0 with: sarif_file: results.sarif From fed82fe8f72830bebc13ea532188f76dc1d2c43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Wed, 13 Nov 2024 13:46:27 -0500 Subject: [PATCH 24/48] add pull number --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d0f183b60..1eca75004 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,7 @@ Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bo Breaking changes ---------------- * The minimum required version of `dask` has been increased to `2024.8.1`. (:issue:`1992`, :pull:`1991`). +* Streamflow variables now expressed as `strf` instead of `q`, with a proper entry in ``variables.yml`` (:issue:`1912`, :pull:`1996`) Bug fixes ^^^^^^^^^ @@ -17,7 +18,6 @@ Bug fixes Internal changes ^^^^^^^^^^^^^^^^ * Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`). -* Streamflow variables now expressed as `strf` instead of `q`, with a proper entry in ``variables.yml`` (:issue:`1912`, :pull:``) v0.53.2 (2024-10-31) -------------------- From cd45420b2df262f5d667b3b7cffe089df2ff88b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Wed, 13 Nov 2024 13:47:41 -0500 Subject: [PATCH 25/48] more specific description change of breaking change --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1eca75004..511709983 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,7 +9,7 @@ Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bo Breaking changes ---------------- * The minimum required version of `dask` has been increased to `2024.8.1`. (:issue:`1992`, :pull:`1991`). -* Streamflow variables now expressed as `strf` instead of `q`, with a proper entry in ``variables.yml`` (:issue:`1912`, :pull:`1996`) +* Streamflow variables now expressed as `strf` instead of `q`, with a proper entry in ``variables.yml``. Many hydroclimatic indicators (e.g. ``flow_index``) signature are changed as a result. (:issue:`1912`, :pull:`1996`) Bug fixes ^^^^^^^^^ From 9e4e6b5f886c2203d3018c75bece37b662d167d5 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:09:05 -0500 Subject: [PATCH 26/48] add measurements to upstream.yml --- .github/workflows/dependency-review.yml | 6 ++--- .github/workflows/upstream.yml | 29 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 8e7d3e05a..dde423557 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -34,7 +34,7 @@ jobs: sum.golang.org:443 - name: Start Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: start-measurement branch: ${{ github.head_ref || github.ref_name }} @@ -46,14 +46,14 @@ jobs: uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a # v4.4.0 - name: Energy Measurement - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: get-measurement label: 'Dependency Review' continue-on-error: true - name: Show Energy Results - uses: green-coding-solutions/eco-ci-energy-estimation@escape-test + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: display-results continue-on-error: true diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index 175c7be54..f5e284a7e 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -44,15 +44,27 @@ jobs: disable-sudo: true egress-policy: block allowed-endpoints: > + api.electricitymap.org:443 api.github.com:443 + api.green-coding.io:443 + api.securityscorecards.dev:443 conda.anaconda.org:443 dap.service.does.not.exist:443 files.pythonhosted.org:443 github.com:443 + ip-api.com:80 + ipapi.co:443 objects.githubusercontent.com:443 + proxy.golang.org:4433 pypi.org:443 raw.githubusercontent.com:443 repo.anaconda.com:443 + sum.golang.org:443 + - name: Start Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 + with: + task: start-measurement + branch: ${{ github.head_ref || github.ref_name }} - name: Checkout Repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -84,6 +96,12 @@ jobs: micromamba list xclim show_version_info python -m pip check || true + - name: Setup Python Measurement + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 + with: + task: get-measurement + label: 'Environment Setup (Upstream, Python${{ matrix.python-version }})' + continue-on-error: true - name: Test Data Caching uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 with: @@ -105,3 +123,14 @@ jobs: with: issue-title: "⚠️ Nightly upstream-dev CI failed for Python${{ matrix.python-version }} ⚠️" log-path: output-${{ matrix.python-version }}-log.jsonl + - name: Tests measurement + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 + with: + task: get-measurement + label: 'Testing and Reporting (Upstream, Python${{ matrix.python-version }})' + continue-on-error: true + - name: Show Energy Results + uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 + with: + task: display-results + continue-on-error: true From bb3cc81cf7c15d0f5b04694603567e536f784d85 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:12:14 -0500 Subject: [PATCH 27/48] handle race condition on teardown --- tests/conftest.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index ba3597b17..0e3785c93 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ # noqa: D104 from __future__ import annotations +import logging import os from functools import partial from pathlib import Path @@ -411,6 +412,12 @@ def remove_data_written_flag(): """Cleanup cache folder once we are finished.""" flag = default_testdata_cache.joinpath(".data_written") if flag.exists(): - flag.unlink() + try: + flag.unlink() + except FileNotFoundError: + logging.info( + "Teardown race condition occurred: .data_written flag already removed. Lucky!" + ) + pass request.addfinalizer(remove_data_written_flag) From aa0d3a22e0fa7df8cfb541e8c21b18c41c655f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Thu, 14 Nov 2024 09:06:40 -0500 Subject: [PATCH 28/48] just q in variables.yml, nothing more --- CHANGELOG.rst | 2 +- tests/conftest.py | 8 ++-- tests/test_generic.py | 28 +++++++------- tests/test_generic_indicators.py | 35 ++++++++--------- tests/test_hydrology.py | 20 +++++----- tests/test_land.py | 26 ++++++------- tests/test_stats.py | 8 ++-- xclim/core/indicator.py | 2 +- xclim/data/fr.json | 4 +- xclim/data/variables.yml | 2 +- xclim/indicators/land/_streamflow.py | 24 ++++++------ xclim/indices/_hydrology.py | 56 ++++++++++++++-------------- 12 files changed, 105 insertions(+), 110 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 511709983..26ac7f02f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,7 +9,6 @@ Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bo Breaking changes ---------------- * The minimum required version of `dask` has been increased to `2024.8.1`. (:issue:`1992`, :pull:`1991`). -* Streamflow variables now expressed as `strf` instead of `q`, with a proper entry in ``variables.yml``. Many hydroclimatic indicators (e.g. ``flow_index``) signature are changed as a result. (:issue:`1912`, :pull:`1996`) Bug fixes ^^^^^^^^^ @@ -18,6 +17,7 @@ Bug fixes Internal changes ^^^^^^^^^^^^^^^^ * Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`). +* `streamflow` entry replaced with `q` in ``variables.yml``. (:issue:`1912`, :pull:`1996`) v0.53.2 (2024-10-31) -------------------- diff --git a/tests/conftest.py b/tests/conftest.py index ca245e0b1..ba3597b17 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -140,8 +140,8 @@ def _pr_series(values, start="1/1/2000", units="kg m-2 s-1"): @pytest.fixture -def strf_series(): - def _strf_series(values, start="1/1/2000", units="m3 s-1"): +def q_series(): + def _q_series(values, start="1/1/2000", units="m3 s-1"): coords = pd.date_range(start, periods=len(values), freq="D") return xr.DataArray( values, @@ -154,11 +154,11 @@ def _strf_series(values, start="1/1/2000", units="m3 s-1"): }, ) - return _strf_series + return _q_series @pytest.fixture -def ndstrf_series(random): +def ndq_series(random): nx, ny, nt = 2, 3, 5000 x = np.arange(0, nx) y = np.arange(0, ny) diff --git a/tests/test_generic.py b/tests/test_generic.py index d95972bcc..8191624a9 100644 --- a/tests/test_generic.py +++ b/tests/test_generic.py @@ -14,27 +14,27 @@ class TestSelectResampleOp: - def test_month(self, strf_series): - q = strf_series(np.arange(1000)) + def test_month(self, q_series): + q = q_series(np.arange(1000)) o = generic.select_resample_op(q, "count", freq="YS", month=3) np.testing.assert_array_equal(o, 31) - def test_season_default(self, strf_series): + def test_season_default(self, q_series): # Will use freq='YS', so count J, F and D of each year. - q = strf_series(np.arange(1000)) + q = q_series(np.arange(1000)) o = generic.select_resample_op(q, "min", season="DJF") assert o[0] == 0 assert o[1] == 366 - def test_season(self, strf_series): - q = strf_series(np.arange(1000)) + def test_season(self, q_series): + q = q_series(np.arange(1000)) o = generic.select_resample_op(q, "count", freq="YS-DEC", season="DJF") assert o[0] == 31 + 29 class TestSelectRollingResampleOp: - def test_rollingmax(self, strf_series): - q = strf_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap + def test_rollingmax(self, q_series): + q = q_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap o = generic.select_rolling_resample_op( q, "max", window=14, window_center=False, window_op="mean" ) @@ -48,8 +48,8 @@ def test_rollingmax(self, strf_series): ) assert o.attrs["units"] == "m3 s-1" - def test_rollingmaxindexer(self, strf_series): - q = strf_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap + def test_rollingmaxindexer(self, q_series): + q = q_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap o = generic.select_rolling_resample_op( q, "min", window=14, window_center=False, window_op="max", season="DJF" ) @@ -58,8 +58,8 @@ def test_rollingmaxindexer(self, strf_series): ) # 14th day for 1st year, then Jan 1st for the next two assert o.attrs["units"] == "m3 s-1" - def test_freq(self, strf_series): - q = strf_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap + def test_freq(self, q_series): + q = q_series(np.arange(1, 366 + 365 + 365 + 1)) # 1st year is leap o = generic.select_rolling_resample_op( q, "max", window=3, window_center=True, window_op="integral", freq="MS" ) @@ -88,13 +88,13 @@ def test_simple(self, tas_series): class TestFlowGeneric: - def test_doyminmax(self, strf_series): + def test_doyminmax(self, q_series): a = np.ones(365) a[9] = 2 a[19] = -2 a[39] = 4 a[49] = -4 - q = strf_series(a) + q = q_series(a) dmx = generic.doymax(q) dmn = generic.doymin(q) assert dmx.values == [40] diff --git a/tests/test_generic_indicators.py b/tests/test_generic_indicators.py index 427e2326c..6411e1479 100644 --- a/tests/test_generic_indicators.py +++ b/tests/test_generic_indicators.py @@ -31,8 +31,8 @@ def test_ndim(self, pr_ndseries, random): assert out.shape == (2, 1, 2) np.testing.assert_array_equal(out.isnull(), False) - def test_options(self, strf_series, random): - q = strf_series(random.random(19)) + def test_options(self, q_series, random): + q = q_series(random.random(19)) out = generic.fit(q, dist="norm") np.testing.assert_array_equal(out.isnull(), False) @@ -42,9 +42,9 @@ def test_options(self, strf_series, random): class TestReturnLevel: - def test_seasonal(self, ndstrf_series): + def test_seasonal(self, ndq_series): out = generic.return_level( - ndstrf_series, mode="max", t=[2, 5], dist="gamma", season="DJF" + ndq_series, mode="max", t=[2, 5], dist="gamma", season="DJF" ) assert out.description == ( @@ -60,8 +60,8 @@ def test_any_variable(self, pr_series, random): out = generic.return_level(pr, mode="max", t=2, dist="gamma") assert out.units == pr.units - def test_no_indexer(self, ndstrf_series): - out = generic.return_level(ndstrf_series, mode="max", t=[2, 5], dist="gamma") + def test_no_indexer(self, ndq_series): + out = generic.return_level(ndq_series, mode="max", t=[2, 5], dist="gamma") assert out.description in [ "Frequency analysis for the maximal annual 1-day value estimated using the gamma distribution." ] @@ -69,14 +69,12 @@ def test_no_indexer(self, ndstrf_series): assert out.shape == (2, 2, 3) # nrt, nx, ny np.testing.assert_array_equal(out.isnull(), False) - def test_q27(self, ndstrf_series): - out = generic.return_level( - ndstrf_series, mode="max", t=2, dist="gamma", window=7 - ) + def test_q27(self, ndq_series): + out = generic.return_level(ndq_series, mode="max", t=2, dist="gamma", window=7) assert out.shape == (1, 2, 3) - def test_empty(self, ndstrf_series): - q = ndstrf_series.copy() + def test_empty(self, ndq_series): + q = ndq_series.copy() q[:, 0, 0] = np.nan out = generic.return_level( q, mode="max", t=2, dist="genextreme", window=6, freq="YS" @@ -96,16 +94,13 @@ def test_simple(self, pr_series, random, op, word): out = generic.stats(pr, freq="YS", op=op) assert out.long_name == f"{word} of variable" - def test_ndq(self, ndstrf_series): - out = generic.stats(ndstrf_series, freq="YS", op="min", season="MAM") + def test_ndq(self, ndq_series): + out = generic.stats(ndq_series, freq="YS", op="min", season="MAM") assert out.attrs["units"] == "m3 s-1" - def test_missing(self, ndstrf_series): - a = ndstrf_series.where( - ~( - (ndstrf_series.time.dt.dayofyear == 5) - & (ndstrf_series.time.dt.year == 1902) - ) + def test_missing(self, ndq_series): + a = ndq_series.where( + ~((ndq_series.time.dt.dayofyear == 5) & (ndq_series.time.dt.year == 1902)) ) assert a.shape == (5000, 2, 3) out = generic.stats(a, op="max", month=1) diff --git a/tests/test_hydrology.py b/tests/test_hydrology.py index a7ae5fe4d..0572d12e1 100644 --- a/tests/test_hydrology.py +++ b/tests/test_hydrology.py @@ -6,19 +6,19 @@ class TestBaseFlowIndex: - def test_simple(self, strf_series): + def test_simple(self, q_series): a = np.zeros(365) + 10 a[10:17] = 1 - q = strf_series(a) + q = q_series(a) out = xci.base_flow_index(q) np.testing.assert_array_equal(out, 1.0 / a.mean()) class TestRBIndex: - def test_simple(self, strf_series): + def test_simple(self, q_series): a = np.zeros(365) a[10] = 10 - q = strf_series(a) + q = q_series(a) out = xci.rb_flashiness_index(q) np.testing.assert_array_equal(out, 2) @@ -73,30 +73,30 @@ def test_simple(self, snw_series, pr_series): class TestFlowindex: - def test_simple(self, strf_series): + def test_simple(self, q_series): a = np.ones(365 * 2) * 10 a[10:50] = 50 - q = strf_series(a) + q = q_series(a) out = xci.flow_index(q, 0.95) np.testing.assert_array_equal(out, 5) class TestHighflowfrequency: - def test_simple(self, strf_series): + def test_simple(self, q_series): a = np.zeros(365 * 2) a[50:60] = 10 a[200:210] = 20 - q = strf_series(a) + q = q_series(a) out = xci.high_flow_frequency(q, 9, freq="YS") np.testing.assert_array_equal(out, [20, 0]) class TestLowflowfrequency: - def test_simple(self, strf_series): + def test_simple(self, q_series): a = np.ones(365 * 2) * 10 a[50:60] = 1 a[200:210] = 1 - q = strf_series(a) + q = q_series(a) out = xci.low_flow_frequency(q, 0.2, freq="YS") np.testing.assert_array_equal(out, [20, 0]) diff --git a/tests/test_land.py b/tests/test_land.py index 4af5c86ca..aedc1563b 100644 --- a/tests/test_land.py +++ b/tests/test_land.py @@ -8,27 +8,27 @@ from xclim import land -def test_base_flow_index(ndstrf_series): - out = land.base_flow_index(ndstrf_series, freq="YS") +def test_base_flow_index(ndq_series): + out = land.base_flow_index(ndq_series, freq="YS") assert out.attrs["units"] == "1" assert isinstance(out, xr.DataArray) -def test_rb_flashiness_index(ndstrf_series): - out = land.base_flow_index(ndstrf_series, freq="YS") +def test_rb_flashiness_index(ndq_series): + out = land.base_flow_index(ndq_series, freq="YS") assert out.attrs["units"] == "1" assert isinstance(out, xr.DataArray) -def test_qdoy_max(ndstrf_series, strf_series): - out = land.doy_strfmax(ndstrf_series, freq="YS", season="JJA") +def test_qdoy_max(ndq_series, q_series): + out = land.doy_qmax(ndq_series, freq="YS", season="JJA") assert out.attrs["units"] == "1" a = np.ones(450) a[100] = 2 - out = land.doy_strfmax(strf_series(a), freq="YS") + out = land.doy_qmax(q_series(a), freq="YS") assert out[0] == 101 @@ -68,20 +68,20 @@ def test_snw_storm_days(snw_series): np.testing.assert_array_equal(out, [9, np.nan]) -def test_flow_index(strf_series): +def test_flow_index(q_series): a = np.ones(365 * 2) * 10 a[10:50] = 50 - q = strf_series(a) + q = q_series(a) out = land.flow_index(q, p=0.95) np.testing.assert_array_equal(out, 5) -def test_high_flow_frequency(strf_series): +def test_high_flow_frequency(q_series): a = np.zeros(366 * 2) * 10 a[50:60] = 10 a[200:210] = 20 - q = strf_series(a) + q = q_series(a) out = land.high_flow_frequency( q, threshold_factor=9, @@ -90,10 +90,10 @@ def test_high_flow_frequency(strf_series): np.testing.assert_array_equal(out, [20, 0, np.nan]) -def test_low_flow_frequency(strf_series): +def test_low_flow_frequency(q_series): a = np.ones(366 * 2) * 10 a[50:60] = 1 a[200:210] = 1 - q = strf_series(a) + q = q_series(a) out = land.low_flow_frequency(q, threshold_factor=0.2, freq="YS") np.testing.assert_array_equal(out, [20, 0, np.nan]) diff --git a/tests/test_stats.py b/tests/test_stats.py index ef41b5955..29a40b3f0 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -266,8 +266,8 @@ def test_pwm_fit(self, dist, use_dask, random): @pytest.mark.parametrize("use_dask", [True, False]) @pytest.mark.filterwarnings("ignore::RuntimeWarning") -def test_frequency_analysis(ndstrf_series, use_dask): - q = ndstrf_series.copy() +def test_frequency_analysis(ndq_series, use_dask): + q = ndq_series.copy() q[:, 0, 0] = np.nan if use_dask: q = q.chunk() @@ -291,9 +291,9 @@ def test_frequency_analysis(ndstrf_series, use_dask): @pytest.mark.parametrize("use_dask", [True, False]) @pytest.mark.filterwarnings("ignore::RuntimeWarning") -def test_frequency_analysis_lmoments(ndstrf_series, use_dask): +def test_frequency_analysis_lmoments(ndq_series, use_dask): lmom = pytest.importorskip("lmoments3.distr") - q = ndstrf_series.copy() + q = ndq_series.copy() q[:, 0, 0] = np.nan if use_dask: q = q.chunk() diff --git a/xclim/core/indicator.py b/xclim/core/indicator.py index 02938058d..1822d04c4 100644 --- a/xclim/core/indicator.py +++ b/xclim/core/indicator.py @@ -1205,7 +1205,7 @@ def json(cls, args=None): param["choices"] = list(param["choices"]) if param["default"] is _empty_default: del param["default"] - elif callable(param): # Rare special case (doy_strfmax and doy_strfmin). + elif callable(param): # Rare special case (doy_qmax and doy_qmin). out["parameters"][name] = f"{param.__module__}.{param.__name__}" return out diff --git a/xclim/data/fr.json b/xclim/data/fr.json index 84a81e531..d42c6b437 100644 --- a/xclim/data/fr.json +++ b/xclim/data/fr.json @@ -716,13 +716,13 @@ "title": "Calcul les paramètres d'une distribution univariée pour un ensemble de données", "abstract": "" }, - "DOY_STRFMAX": { + "DOY_QMAX": { "long_name": "Jour de l'année du maximum du débit en {indexer:nom}", "description": "Jour de l'année du maximum du débit en {indexer:nom}.", "title": "Jour de l'année du maximum du débit", "abstract": "" }, - "DOY_STRFMIN": { + "DOY_QMIN": { "long_name": "Jour de l'année du minimum du débit en {indexer:nom}", "description": "Jour de l'année du minimum du débit en {indexer:nom}.", "title": "Jour de l'année du minimum du débit", diff --git a/xclim/data/variables.yml b/xclim/data/variables.yml index 29362380e..a02194514 100644 --- a/xclim/data/variables.yml +++ b/xclim/data/variables.yml @@ -237,7 +237,7 @@ variables: standard_name: lwe_thickness_of_snow_amount data_flags: - negative_accumulation_values: - strf: + streamflow: canonical_units: m3 s-1 cell_methods: "time: mean" description: The amount of water, in all phases, flowing in the river channel and flood plain. diff --git a/xclim/indicators/land/_streamflow.py b/xclim/indicators/land/_streamflow.py index 0e94b414b..fc73699af 100644 --- a/xclim/indicators/land/_streamflow.py +++ b/xclim/indicators/land/_streamflow.py @@ -19,8 +19,8 @@ __all__ = [ "base_flow_index", - "doy_strfmax", - "doy_strfmin", + "doy_qmax", + "doy_qmin", "flow_index", "high_flow_frequency", "low_flow_frequency", @@ -37,8 +37,8 @@ class Streamflow(ResamplingIndicator): # TODO: TJS: The signature of this method seems wrong. Should it be `def cfcheck(cls, q):` or something else? Is it a static method? @staticmethod - def cfcheck(strf): - check_valid(strf, "standard_name", "water_volume_transport_in_river_channel") + def cfcheck(q): + check_valid(q, "standard_name", "water_volume_transport_in_river_channel") base_flow_index = Streamflow( @@ -65,10 +65,10 @@ def cfcheck(strf): ) -doy_strfmax = Streamflow( +doy_qmax = Streamflow( title="Day of year of the maximum streamflow", identifier="doy_qmax", - var_name="strf{indexer}_doy_strfmax", + var_name="q{indexer}_doy_qmax", long_name="Day of the year of the maximum streamflow over {indexer}", description="Day of the year of the maximum streamflow over {indexer}.", units="", @@ -77,10 +77,10 @@ def cfcheck(strf): ) -doy_strfmin = Streamflow( +doy_qmin = Streamflow( title="Day of year of the minimum streamflow", - identifier="doy_strfmin", - var_name="strf{indexer}_doy_strfmin", + identifier="doy_qmin", + var_name="q{indexer}_doy_qmin", long_name="Day of the year of the minimum streamflow over {indexer}", description="Day of the year of the minimum streamflow over {indexer}.", units="", @@ -93,7 +93,7 @@ def cfcheck(strf): context="hydro", title="Flow index", identifier="flow_index", - var_name="strf_flow_index", + var_name="q_flow_index", long_name="Flow index", description="{p}th percentile normalized by the median flow.", units="1", @@ -104,7 +104,7 @@ def cfcheck(strf): high_flow_frequency = Streamflow( title="High flow frequency", identifier="high_flow_frequency", - var_name="strf_high_flow_frequency", + var_name="q_high_flow_frequency", long_name="High flow frequency", description="{freq} frequency of flows greater than {threshold_factor} times the median flow.", units="days", @@ -115,7 +115,7 @@ def cfcheck(strf): low_flow_frequency = Streamflow( title="Low flow frequency", identifier="low_flow_frequency", - var_name="strf_low_flow_frequency", + var_name="q_low_flow_frequency", long_name="Low flow frequency", description="{freq} frequency of flows smaller than a fraction ({threshold_factor}) of the mean flow.", units="days", diff --git a/xclim/indices/_hydrology.py b/xclim/indices/_hydrology.py index 0781b524e..23d320cbc 100644 --- a/xclim/indices/_hydrology.py +++ b/xclim/indices/_hydrology.py @@ -26,15 +26,15 @@ ] -@declare_units(strf="[discharge]") -def base_flow_index(strf: xr.DataArray, freq: str = "YS") -> xr.DataArray: +@declare_units(q="[discharge]") +def base_flow_index(q: xr.DataArray, freq: str = "YS") -> xr.DataArray: r"""Base flow index. Return the base flow index, defined as the minimum 7-day average flow divided by the mean flow. Parameters ---------- - strf : xarray.DataArray + q : xarray.DataArray Rate of river discharge. freq : str Resampling frequency. @@ -61,8 +61,8 @@ def base_flow_index(strf: xr.DataArray, freq: str = "YS") -> xr.DataArray: \mathrm{CMA}_7(q_i) = \frac{\sum_{j=i-3}^{i+3} q_j}{7} """ - m7 = strf.rolling(time=7, center=True).mean(skipna=False).resample(time=freq) - mq = strf.resample(time=freq) + m7 = q.rolling(time=7, center=True).mean(skipna=False).resample(time=freq) + mq = q.resample(time=freq) m7m = m7.min(dim="time") out = m7m / mq.mean(dim="time") @@ -70,8 +70,8 @@ def base_flow_index(strf: xr.DataArray, freq: str = "YS") -> xr.DataArray: return out -@declare_units(strf="[discharge]") -def rb_flashiness_index(strf: xr.DataArray, freq: str = "YS") -> xr.DataArray: +@declare_units(q="[discharge]") +def rb_flashiness_index(q: xr.DataArray, freq: str = "YS") -> xr.DataArray: r"""Richards-Baker flashiness index. Measures oscillations in flow relative to total flow, quantifying the frequency and rapidity of short term changes @@ -79,7 +79,7 @@ def rb_flashiness_index(strf: xr.DataArray, freq: str = "YS") -> xr.DataArray: Parameters ---------- - strf : xarray.DataArray + q : xarray.DataArray Rate of river discharge. freq : str Resampling frequency. @@ -101,8 +101,8 @@ def rb_flashiness_index(strf: xr.DataArray, freq: str = "YS") -> xr.DataArray: ---------- :cite:cts:`baker_new_2004` """ - d = np.abs(strf.diff(dim="time")).resample(time=freq) - mq = strf.resample(time=freq) + d = np.abs(q.diff(dim="time")).resample(time=freq) + mq = q.resample(time=freq) out = d.sum(dim="time") / mq.sum(dim="time") out.attrs["units"] = "" return out @@ -285,8 +285,8 @@ def melt_and_precip_max( return out -@declare_units(strf="[discharge]") -def flow_index(strf: xr.DataArray, p: float = 0.95) -> xr.DataArray: +@declare_units(q="[discharge]") +def flow_index(q: xr.DataArray, p: float = 0.95) -> xr.DataArray: """ Flow index @@ -294,7 +294,7 @@ def flow_index(strf: xr.DataArray, p: float = 0.95) -> xr.DataArray: Parameters ---------- - strf : xr.DataArray + q : xr.DataArray Daily streamflow data. p : float Percentile for calculating the flow index, between 0 and 1. Default of 0.95 is for high flows. @@ -308,16 +308,16 @@ def flow_index(strf: xr.DataArray, p: float = 0.95) -> xr.DataArray: ---------- :cite:cts:`Clausen2000` """ - strfp = strf.quantile(p, dim="time") - strf_median = strf.median(dim="time") - out = strfp / strf_median + qp = q.quantile(p, dim="time") + q_median = q.median(dim="time") + out = qp / q_median out.attrs["units"] = "1" return out -@declare_units(strf="[discharge]") +@declare_units(q="[discharge]") def high_flow_frequency( - strf: xr.DataArray, threshold_factor: int = 9, freq: str = "YS-OCT" + q: xr.DataArray, threshold_factor: int = 9, freq: str = "YS-OCT" ) -> xr.DataArray: """ High flow frequency. @@ -328,7 +328,7 @@ def high_flow_frequency( Parameters ---------- - strf : xr.DataArray + q : xr.DataArray Daily streamflow data. threshold_factor : int Factor by which the median flow is multiplied to set the high flow threshold, default is 9. @@ -344,15 +344,15 @@ def high_flow_frequency( ---------- :cite:cts:`addor2018,Clausen2000` """ - median_flow = strf.median(dim="time") + median_flow = q.median(dim="time") threshold = threshold_factor * median_flow - out = threshold_count(strf, ">", threshold, freq=freq) - return to_agg_units(out, strf, "count") + out = threshold_count(q, ">", threshold, freq=freq) + return to_agg_units(out, q, "count") -@declare_units(strf="[discharge]") +@declare_units(q="[discharge]") def low_flow_frequency( - strf: xr.DataArray, threshold_factor: float = 0.2, freq: str = "YS-OCT" + q: xr.DataArray, threshold_factor: float = 0.2, freq: str = "YS-OCT" ) -> xr.DataArray: """ Low flow frequency. @@ -363,7 +363,7 @@ def low_flow_frequency( Parameters ---------- - strf : xr.DataArray + q : xr.DataArray Daily streamflow data. threshold_factor : float Factor by which the mean flow is multiplied to set the low flow threshold, default is 0.2. @@ -379,7 +379,7 @@ def low_flow_frequency( ---------- :cite:cts:`Olden2003` """ - mean_flow = strf.mean(dim="time") + mean_flow = q.mean(dim="time") threshold = threshold_factor * mean_flow - out = threshold_count(strf, "<", threshold, freq=freq) - return to_agg_units(out, strf, "count") + out = threshold_count(q, "<", threshold, freq=freq) + return to_agg_units(out, q, "count") From 6acb4d2c8ce58151bc4d949b8b26c4f0f04baf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Thu, 14 Nov 2024 09:07:43 -0500 Subject: [PATCH 29/48] add the change --- xclim/data/variables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xclim/data/variables.yml b/xclim/data/variables.yml index a02194514..71a7b7dd0 100644 --- a/xclim/data/variables.yml +++ b/xclim/data/variables.yml @@ -237,7 +237,7 @@ variables: standard_name: lwe_thickness_of_snow_amount data_flags: - negative_accumulation_values: - streamflow: + q: canonical_units: m3 s-1 cell_methods: "time: mean" description: The amount of water, in all phases, flowing in the river channel and flood plain. From fe4066eb8d66ab954143aa0f5c08a2265ca90d34 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:10:21 -0500 Subject: [PATCH 30/48] Fix nimbus URL joining (#1997) ### What kind of change does this PR introduce? * Fixed an issue that was causing URLs to include a `//` between the repository and branch fields. ### Does this PR introduce a breaking change? No. ### Other information: While this was working fine for returning files already available on disk, when `nimbus` was fetching files remotely when launched from a Jupyter notebook, this was failing. Related: https://github.com/Ouranosinc/xscen/pull/492 --- CHANGELOG.rst | 1 + xclim/testing/utils.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f85d72b51..15dd45bfe 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,6 +13,7 @@ Breaking changes Bug fixes ^^^^^^^^^ * Fixed pickling issue with ``xclim.sdba.Grouper`` and other classes for usage with `dask>=2024.11`. (:issue:`1992`, :pull:`1993`). +* Fixed an issue with ``nimbus`` that was causing URL path components to be improperly joined. (:pull:`1997`). Internal changes ^^^^^^^^^^^^^^^^ diff --git a/xclim/testing/utils.py b/xclim/testing/utils.py index dad66b212..25a626bd7 100644 --- a/xclim/testing/utils.py +++ b/xclim/testing/utils.py @@ -435,7 +435,12 @@ def load_registry( dict Dictionary of filenames and hashes. """ - remote_registry = audit_url(f"{repo}/{branch}/data/registry.txt") + remote_registry = audit_url( + urljoin( + urljoin(repo, branch if branch.endswith("/") else f"{branch}/"), + "data/registry.txt", + ) + ) if branch != default_testdata_version: custom_registry_folder = Path( @@ -511,8 +516,9 @@ def nimbus( # noqa: PR01 "The `pooch` package is required to fetch the xclim testing data. " "You can install it with `pip install pooch` or `pip install xclim[dev]`." ) - - remote = audit_url(f"{repo}/{branch}/data") + remote = audit_url( + urljoin(urljoin(repo, branch if branch.endswith("/") else f"{branch}/"), "data") + ) return pooch.create( path=cache_dir, base_url=remote, From d578b33ca20497e61ae002df2ae962a19e9d9bee Mon Sep 17 00:00:00 2001 From: Ouranos Helper Bot Date: Fri, 15 Nov 2024 19:10:53 +0000 Subject: [PATCH 31/48] =?UTF-8?q?Bump=20version:=200.53.3-dev.1=20?= =?UTF-8?q?=E2=86=92=200.53.3-dev.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- xclim/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1290119f6..f4029a8db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,7 +134,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.53.3-dev.1" +current_version = "0.53.3-dev.2" commit = true commit_args = "--no-verify" tag = false diff --git a/xclim/__init__.py b/xclim/__init__.py index f9468bfe2..9010e312d 100644 --- a/xclim/__init__.py +++ b/xclim/__init__.py @@ -13,7 +13,7 @@ __author__ = """Travis Logan""" __email__ = "logan.travis@ouranos.ca" -__version__ = "0.53.3-dev.1" +__version__ = "0.53.3-dev.2" with _resources.as_file(_resources.files("xclim.data")) as _module_data: From 13a91cbe6e2d807ed08e9bae331285a974221066 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:46:30 -0500 Subject: [PATCH 32/48] update CHANGELOG.rst --- CHANGELOG.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f85d72b51..67c7632a7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,7 +7,7 @@ v0.54.0 (unreleased) Contributors to this version: Trevor James Smith (:user:`Zeitsperre`), Pascal Bourgault (:user:`aulemahal`). Breaking changes ----------------- +^^^^^^^^^^^^^^^^ * The minimum required version of `dask` has been increased to `2024.8.1`. (:issue:`1992`, :pull:`1991`). Bug fixes @@ -16,7 +16,12 @@ Bug fixes Internal changes ^^^^^^^^^^^^^^^^ -* Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`). +* Changed French translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`). +* Addressed a very rare race condition that can happen if `pytest` is tearing down the test environment when running across multiple workers. (:pull:`1863`). + +CI changes +^^^^^^^^^^ +* Added the `green-coding-solutions/eco-ci-energy-estimation` GitHub Action to the workflows to establish energy and carbon usage of CI activity. (:pull:`1863`). v0.53.2 (2024-10-31) -------------------- From 415ba6d2c8109cceb4adbe70d22ef2ebc007b96c Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:55:24 -0500 Subject: [PATCH 33/48] add pr comment --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c9dc334f6..2c34f0b56 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -449,4 +449,5 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: display-results + pr-comment: true continue-on-error: true From 2deb619e76df54948906e75cefaf280bec2c435c Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:17:18 -0500 Subject: [PATCH 34/48] update permissions --- .github/workflows/main.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2c34f0b56..3a3968d84 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -423,12 +423,27 @@ jobs: - test-pypi - test-conda runs-on: ubuntu-latest + permissions: + pull-requests: write steps: - name: Harden Runner uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: disable-sudo: true - egress-policy: audit + egress-policy: block + allowed-endpoints: > + api.electricitymap.org:443 + api.github.com:443 + api.green-coding.io:443 + coveralls.io:443 + files.pythonhosted.org:443 + github.com:443 + ip-api.com:80 + ipapi.co:443 + objects.githubusercontent.com:443 + proxy.golang.org:443 + pypi.org:443 + sum.golang.org:443 - name: Start Energy Measurement uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: From 14e0cd0767b566cc46c529d9dea66d4fb178cb0c Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:02:55 -0500 Subject: [PATCH 35/48] remove pr comment, add badge --- .github/workflows/main.yml | 1 - README.rst | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3a3968d84..1faca5919 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -464,5 +464,4 @@ jobs: uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0 with: task: display-results - pr-comment: true continue-on-error: true diff --git a/README.rst b/README.rst index 05d940f5a..227260d9e 100644 --- a/README.rst +++ b/README.rst @@ -11,7 +11,7 @@ xclim: Climate services library |logo| |logo-dark| |logo-light| +----------------------------+-----------------------------------------------------+ | Coding Standards | |black| |ruff| |pre-commit| |security| |fossa| | +----------------------------+-----------------------------------------------------+ -| Development Status | |status| |build| |coveralls| | +| Development Status | |status| |build| |coveralls| |energy| | +----------------------------+-----------------------------------------------------+ `xclim` is an operational Python library for climate services, providing numerous climate-related indicator tools @@ -168,6 +168,10 @@ This package was created with Cookiecutter_ and the `audreyfeldroy/cookiecutter- :target: https://bestpractices.coreinfrastructure.org/projects/6041 :alt: Open Source Security Foundation +.. |energy| image:: https://api.green-coding.io/v1/ci/badge/get?repo=Ouranosinc/xclim&branch=main/merge&workflow=47013755 + :target: https://metrics.green-coding.io/ci.html?repo=Ouranosinc/xclim&branch=main/merge&workflow=47013755 + :alt: Energy Consumption + .. |fair| image:: https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8B-yellow :target: https://fair-software.eu :alt: FAIR Software Compliance From 770ccdd335731bca6811a6b0a625abe36ef73a4c Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:08:24 -0500 Subject: [PATCH 36/48] fix URL --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 227260d9e..f02d9dbff 100644 --- a/README.rst +++ b/README.rst @@ -168,8 +168,8 @@ This package was created with Cookiecutter_ and the `audreyfeldroy/cookiecutter- :target: https://bestpractices.coreinfrastructure.org/projects/6041 :alt: Open Source Security Foundation -.. |energy| image:: https://api.green-coding.io/v1/ci/badge/get?repo=Ouranosinc/xclim&branch=main/merge&workflow=47013755 - :target: https://metrics.green-coding.io/ci.html?repo=Ouranosinc/xclim&branch=main/merge&workflow=47013755 +.. |energy| image:: https://api.green-coding.io/v1/ci/badge/get?repo=Ouranosinc/xclim&branch=main&workflow=47013755 + :target: https://metrics.green-coding.io/ci.html?repo=Ouranosinc/xclim&branch=main&workflow=47013755 :alt: Energy Consumption .. |fair| image:: https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8B-yellow From 662030eb34c3d98339c5aee3e873861d235eced1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 12:55:04 +0000 Subject: [PATCH 37/48] Bump deptry from 0.21.0 to 0.21.1 in the python group Bumps the python group with 1 update: [deptry](https://github.com/fpgmaas/deptry). Updates `deptry` from 0.21.0 to 0.21.1 - [Release notes](https://github.com/fpgmaas/deptry/releases) - [Changelog](https://github.com/fpgmaas/deptry/blob/main/CHANGELOG.md) - [Commits](https://github.com/fpgmaas/deptry/compare/0.21.0...0.21.1) --- updated-dependencies: - dependency-name: deptry dependency-type: direct:production update-type: version-update:semver-patch dependency-group: python ... Signed-off-by: dependabot[bot] --- CI/requirements_ci.in | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CI/requirements_ci.in b/CI/requirements_ci.in index b95fdf60e..d4c6ec4ab 100644 --- a/CI/requirements_ci.in +++ b/CI/requirements_ci.in @@ -1,5 +1,5 @@ bump-my-version==0.28.1 -deptry==0.21.0 +deptry==0.21.1 flit==3.10.1 pip==24.3.1 pylint==3.3.1 diff --git a/pyproject.toml b/pyproject.toml index f4029a8db..91f4f18da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ dev = [ "codespell ==2.3.0", "coverage[toml] >=7.5.0", "coveralls >=4.0.1", # coveralls is not yet compatible with Python 3.13 - "deptry ==0.21.0", + "deptry ==0.21.1", "flake8 >=7.1.1", "flake8-rst-docstrings >=0.3.0", "h5netcdf>=1.3.0", From dbef92087c5be6d1988f8d106b51097696689d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Tue, 19 Nov 2024 10:22:55 -0500 Subject: [PATCH 38/48] only local changes for base_kws_vars --- CHANGELOG.rst | 1 + xclim/sdba/adjustment.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 15dd45bfe..c2b931d9e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,7 @@ Bug fixes ^^^^^^^^^ * Fixed pickling issue with ``xclim.sdba.Grouper`` and other classes for usage with `dask>=2024.11`. (:issue:`1992`, :pull:`1993`). * Fixed an issue with ``nimbus`` that was causing URL path components to be improperly joined. (:pull:`1997`). +* `base_kws_vars` in `MBCn` is now copied inside the `adjust` function so that in-place changes do not change the dict globally. Internal changes ^^^^^^^^^^^^^^^^ diff --git a/xclim/sdba/adjustment.py b/xclim/sdba/adjustment.py index 5c8506071..be1981d53 100644 --- a/xclim/sdba/adjustment.py +++ b/xclim/sdba/adjustment.py @@ -5,6 +5,7 @@ """ from __future__ import annotations +import copy from importlib.util import find_spec from inspect import signature from typing import Any @@ -1818,7 +1819,7 @@ def _adjust( period_dim=None, ): # set default values for non-specified parameters - base_kws_vars = base_kws_vars or {} + base_kws_vars = copy.deepcopy(base_kws_vars) or {} pts_dim = self.pts_dims[0] for v in sim[pts_dim].values: base_kws_vars.setdefault(v, {}) From 13965d913d794c8786f7cf4ca89211ec0aa2b932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Tue, 19 Nov 2024 10:26:02 -0500 Subject: [PATCH 39/48] add pull number --- CHANGELOG.rst | 2 +- xclim/sdba/adjustment.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c2b931d9e..aed32045a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,7 +14,7 @@ Bug fixes ^^^^^^^^^ * Fixed pickling issue with ``xclim.sdba.Grouper`` and other classes for usage with `dask>=2024.11`. (:issue:`1992`, :pull:`1993`). * Fixed an issue with ``nimbus`` that was causing URL path components to be improperly joined. (:pull:`1997`). -* `base_kws_vars` in `MBCn` is now copied inside the `adjust` function so that in-place changes do not change the dict globally. +* `base_kws_vars` in `MBCn` is now copied inside the `adjust` function so that in-place changes do not change the dict globally. (:pull:`1999`). Internal changes ^^^^^^^^^^^^^^^^ diff --git a/xclim/sdba/adjustment.py b/xclim/sdba/adjustment.py index be1981d53..5a1c5db01 100644 --- a/xclim/sdba/adjustment.py +++ b/xclim/sdba/adjustment.py @@ -5,7 +5,7 @@ """ from __future__ import annotations -import copy +from copy import deepcopy from importlib.util import find_spec from inspect import signature from typing import Any @@ -1819,7 +1819,7 @@ def _adjust( period_dim=None, ): # set default values for non-specified parameters - base_kws_vars = copy.deepcopy(base_kws_vars) or {} + base_kws_vars = deepcopy(base_kws_vars) or {} pts_dim = self.pts_dims[0] for v in sim[pts_dim].values: base_kws_vars.setdefault(v, {}) From d31f51ec73e76b1999a47eeb651dbe29e98721ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Dupuis?= Date: Tue, 19 Nov 2024 10:27:26 -0500 Subject: [PATCH 40/48] check None first --- xclim/sdba/adjustment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xclim/sdba/adjustment.py b/xclim/sdba/adjustment.py index 5a1c5db01..da5ab54fe 100644 --- a/xclim/sdba/adjustment.py +++ b/xclim/sdba/adjustment.py @@ -1819,7 +1819,7 @@ def _adjust( period_dim=None, ): # set default values for non-specified parameters - base_kws_vars = deepcopy(base_kws_vars) or {} + base_kws_vars = {} if base_kws_vars is None else deepcopy(base_kws_vars) pts_dim = self.pts_dims[0] for v in sim[pts_dim].values: base_kws_vars.setdefault(v, {}) From 6121ec70d2df28a88ba851b1942f645619783ca3 Mon Sep 17 00:00:00 2001 From: Ouranos Helper Bot Date: Tue, 19 Nov 2024 16:30:40 +0000 Subject: [PATCH 41/48] =?UTF-8?q?Bump=20version:=200.53.3-dev.2=20?= =?UTF-8?q?=E2=86=92=200.53.3-dev.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- xclim/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 91f4f18da..dfd27d3d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,7 +134,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.53.3-dev.2" +current_version = "0.53.3-dev.3" commit = true commit_args = "--no-verify" tag = false diff --git a/xclim/__init__.py b/xclim/__init__.py index 9010e312d..6f5891522 100644 --- a/xclim/__init__.py +++ b/xclim/__init__.py @@ -13,7 +13,7 @@ __author__ = """Travis Logan""" __email__ = "logan.travis@ouranos.ca" -__version__ = "0.53.3-dev.2" +__version__ = "0.53.3-dev.3" with _resources.as_file(_resources.files("xclim.data")) as _module_data: From 89f169556f21599fa37cb7e70a991df4c1f50704 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:02:37 -0500 Subject: [PATCH 42/48] overload the fetch argument of nimbus to add a User-Agent --- xclim/testing/utils.py | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/xclim/testing/utils.py b/xclim/testing/utils.py index 25a626bd7..182a39adf 100644 --- a/xclim/testing/utils.py +++ b/xclim/testing/utils.py @@ -13,13 +13,14 @@ import sys import time import warnings -from collections.abc import Sequence +from collections.abc import Callable, Sequence from datetime import datetime as dt +from functools import wraps from importlib import import_module from io import StringIO from pathlib import Path from shutil import copytree -from typing import TextIO +from typing import IO, TextIO from urllib.error import HTTPError, URLError from urllib.parse import urljoin, urlparse from urllib.request import urlretrieve @@ -519,7 +520,8 @@ def nimbus( # noqa: PR01 remote = audit_url( urljoin(urljoin(repo, branch if branch.endswith("/") else f"{branch}/"), "data") ) - return pooch.create( + + _nimbus = pooch.create( path=cache_dir, base_url=remote, version=default_testdata_version, @@ -528,6 +530,35 @@ def nimbus( # noqa: PR01 registry=load_registry(branch=branch, repo=repo), ) + # Add a custom fetch method to the Pooch instance + # Needed to address: https://github.com/readthedocs/readthedocs.org/issues/11763 + # Fix inspired by @bjlittle (https://github.com/bjlittle/geovista/pull/1202) + _nimbus.fetch_diversion = _nimbus.fetch + + # Overload the fetch method to add user-agent headers + @wraps(_nimbus.fetch_diversion) + def _fetch(*args: str, **kwargs: bool | Callable) -> str: # numpydoc ignore=GL08 + + def _downloader( + url: str, + output_file: str | IO, + poocher: pooch.Pooch, + check_only: bool | None = False, + ) -> None: + """Download the file from the URL and save it to the save_path.""" + headers = {"User-Agent": f"xclim ({__xclim_version__})"} + downloader = pooch.HTTPDownloader(headers=headers) + return downloader(url, output_file, poocher, check_only=check_only) + + # default to our http/s downloader with user-agent headers + kwargs.setdefault("downloader", _downloader) + return _nimbus.fetch_diversion(*args, **kwargs) + + # Replace the fetch method with the custom fetch method + _nimbus.fetch = _fetch + + return _nimbus + # idea copied from raven that it borrowed from xclim that borrowed it from xarray that was borrowed from Seaborn def open_dataset( From fc14674640853dc176ae1ed8ff262954717d57ef Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:36:20 -0500 Subject: [PATCH 43/48] better support of external testdata repositories --- xclim/testing/utils.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/xclim/testing/utils.py b/xclim/testing/utils.py index 182a39adf..7de871a76 100644 --- a/xclim/testing/utils.py +++ b/xclim/testing/utils.py @@ -436,6 +436,8 @@ def load_registry( dict Dictionary of filenames and hashes. """ + if not repo.endswith("/"): + repo = f"{repo}/" remote_registry = audit_url( urljoin( urljoin(repo, branch if branch.endswith("/") else f"{branch}/"), @@ -443,7 +445,7 @@ def load_registry( ) ) - if branch != default_testdata_version: + if repo == default_testdata_repo_url and branch != default_testdata_version: custom_registry_folder = Path( str(ilr.files("xclim").joinpath(f"testing/{branch}")) ) @@ -452,10 +454,20 @@ def load_registry( urlretrieve(remote_registry, registry_file) # noqa: S310 elif repo != default_testdata_repo_url: - registry_file = Path(str(ilr.files("xclim").joinpath("testing/registry.txt"))) + external_repo_name = urlparse(repo).path.split("/")[-2] + external_branch_name = branch.split("/")[-1] + registry_file = Path( + str( + ilr.files("xclim").joinpath( + f"testing/registry.{external_repo_name}.{external_branch_name}.txt" + ) + ) + ) urlretrieve(remote_registry, registry_file) # noqa: S310 - registry_file = Path(str(ilr.files("xclim").joinpath("testing/registry.txt"))) + else: + registry_file = Path(str(ilr.files("xclim").joinpath("testing/registry.txt"))) + if not registry_file.exists(): raise FileNotFoundError(f"Registry file not found: {registry_file}") @@ -517,6 +529,8 @@ def nimbus( # noqa: PR01 "The `pooch` package is required to fetch the xclim testing data. " "You can install it with `pip install pooch` or `pip install xclim[dev]`." ) + if not repo.endswith("/"): + repo = f"{repo}/" remote = audit_url( urljoin(urljoin(repo, branch if branch.endswith("/") else f"{branch}/"), "data") ) From 412219fc71157f0abfce88a473b0da165633d911 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:10:03 -0500 Subject: [PATCH 44/48] cleaner --- xclim/testing/utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xclim/testing/utils.py b/xclim/testing/utils.py index 7de871a76..1969b6519 100644 --- a/xclim/testing/utils.py +++ b/xclim/testing/utils.py @@ -445,15 +445,7 @@ def load_registry( ) ) - if repo == default_testdata_repo_url and branch != default_testdata_version: - custom_registry_folder = Path( - str(ilr.files("xclim").joinpath(f"testing/{branch}")) - ) - custom_registry_folder.mkdir(parents=True, exist_ok=True) - registry_file = custom_registry_folder.joinpath("registry.txt") - urlretrieve(remote_registry, registry_file) # noqa: S310 - - elif repo != default_testdata_repo_url: + if repo != default_testdata_repo_url: external_repo_name = urlparse(repo).path.split("/")[-2] external_branch_name = branch.split("/")[-1] registry_file = Path( @@ -465,6 +457,14 @@ def load_registry( ) urlretrieve(remote_registry, registry_file) # noqa: S310 + elif branch != default_testdata_version: + custom_registry_folder = Path( + str(ilr.files("xclim").joinpath(f"testing/{branch}")) + ) + custom_registry_folder.mkdir(parents=True, exist_ok=True) + registry_file = custom_registry_folder.joinpath("registry.txt") + urlretrieve(remote_registry, registry_file) # noqa: S310 + else: registry_file = Path(str(ilr.files("xclim").joinpath("testing/registry.txt"))) From 2f57a894c6c316f118e4e9eb455d82af1f7f6cdd Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:33:14 -0500 Subject: [PATCH 45/48] update CHANGELOG.rst --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index aed32045a..223085d08 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,10 +15,12 @@ Bug fixes * Fixed pickling issue with ``xclim.sdba.Grouper`` and other classes for usage with `dask>=2024.11`. (:issue:`1992`, :pull:`1993`). * Fixed an issue with ``nimbus`` that was causing URL path components to be improperly joined. (:pull:`1997`). * `base_kws_vars` in `MBCn` is now copied inside the `adjust` function so that in-place changes do not change the dict globally. (:pull:`1999`). +* Fixed a bug in the logic of ``xclim.testing.utils.load_registry`` that impacted the ability to load a `registry.txt` from a non-default repository. (:pull:`2001`). Internal changes ^^^^^^^^^^^^^^^^ * Changed french translations with word "pluvieux" to "avec précipitations". (:issue:`1960`, :pull:`1994`). +* In order to address 403 (forbidden) request errors when retrieving data from GitHub via ReadTheDocs, the ``nimbus`` class has been modified to use an overloaded `fetch` method that appends a User-Agent header to the request. (:pull:`2001`). v0.53.2 (2024-10-31) -------------------- From aaf115c81509809054b9d2642efbbfc567890296 Mon Sep 17 00:00:00 2001 From: Ouranos Helper Bot Date: Wed, 20 Nov 2024 21:51:12 +0000 Subject: [PATCH 46/48] =?UTF-8?q?Bump=20version:=200.53.3-dev.3=20?= =?UTF-8?q?=E2=86=92=200.53.3-dev.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- xclim/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dfd27d3d3..b34efcc0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,7 +134,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.53.3-dev.3" +current_version = "0.53.3-dev.4" commit = true commit_args = "--no-verify" tag = false diff --git a/xclim/__init__.py b/xclim/__init__.py index 6f5891522..c4a9153d9 100644 --- a/xclim/__init__.py +++ b/xclim/__init__.py @@ -13,7 +13,7 @@ __author__ = """Travis Logan""" __email__ = "logan.travis@ouranos.ca" -__version__ = "0.53.3-dev.3" +__version__ = "0.53.3-dev.4" with _resources.as_file(_resources.files("xclim.data")) as _module_data: From abcf6821a6aaa3e785d680f440f009f943d08261 Mon Sep 17 00:00:00 2001 From: Ouranos Helper Bot Date: Fri, 22 Nov 2024 17:16:19 +0000 Subject: [PATCH 47/48] =?UTF-8?q?Bump=20version:=200.53.3-dev.4=20?= =?UTF-8?q?=E2=86=92=200.53.3-dev.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- xclim/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b34efcc0f..519490b32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,7 +134,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.53.3-dev.4" +current_version = "0.53.3-dev.5" commit = true commit_args = "--no-verify" tag = false diff --git a/xclim/__init__.py b/xclim/__init__.py index c4a9153d9..267fa7753 100644 --- a/xclim/__init__.py +++ b/xclim/__init__.py @@ -13,7 +13,7 @@ __author__ = """Travis Logan""" __email__ = "logan.travis@ouranos.ca" -__version__ = "0.53.3-dev.4" +__version__ = "0.53.3-dev.5" with _resources.as_file(_resources.files("xclim.data")) as _module_data: From 88650baee96995663b659e25394d7b2a684ea8c5 Mon Sep 17 00:00:00 2001 From: Ouranos Helper Bot Date: Fri, 22 Nov 2024 17:33:07 +0000 Subject: [PATCH 48/48] =?UTF-8?q?Bump=20version:=200.53.3-dev.5=20?= =?UTF-8?q?=E2=86=92=200.53.3-dev.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- xclim/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 519490b32..daf1cbfe8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,7 +134,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.53.3-dev.5" +current_version = "0.53.3-dev.6" commit = true commit_args = "--no-verify" tag = false diff --git a/xclim/__init__.py b/xclim/__init__.py index 267fa7753..c4c1de29a 100644 --- a/xclim/__init__.py +++ b/xclim/__init__.py @@ -13,7 +13,7 @@ __author__ = """Travis Logan""" __email__ = "logan.travis@ouranos.ca" -__version__ = "0.53.3-dev.5" +__version__ = "0.53.3-dev.6" with _resources.as_file(_resources.files("xclim.data")) as _module_data: