From fa78d56f2ed53a231b9ca1d0cc782e96e4a6c004 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 11 Feb 2025 16:51:18 -0500 Subject: [PATCH 1/6] add FutureWarning notices for sdba, add temporary workflow concerning changes to xclim.sdba --- .github/workflows/sdba-warning.yml | 81 ++++++++++++++++++++++++++++++ docs/api.rst | 12 +++++ src/xclim/sdba/__init__.py | 15 ++++++ 3 files changed, 108 insertions(+) create mode 100644 .github/workflows/sdba-warning.yml diff --git a/.github/workflows/sdba-warning.yml b/.github/workflows/sdba-warning.yml new file mode 100644 index 000000000..042557e8b --- /dev/null +++ b/.github/workflows/sdba-warning.yml @@ -0,0 +1,81 @@ +name: Workflow Changes Warnings + +on: + # Note: potential security risk from this action using pull_request_target. + # Do not add actions in here which need a checkout of the repo, and do not use any caching in here. + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target + pull_request_target: + types: + - opened + - reopened + - synchronize + paths: + - src/xclim/sdba/*.py + +permissions: + contents: read + +jobs: + comment-concerning-workflow-changes: + name: Comment Concerning Changes to SDBA module + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - name: Harden Runner + uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 + with: + disable-sudo: true + egress-policy: block + allowed-endpoints: > + api.github.com:443 + - name: Find Warning Comment + uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 + id: fc_warning + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: | + This Pull Request modifies the SDBA module. + - name: Create Warning Comment + if: | + (steps.fc_warning.outputs.comment-id == '') && + (!contains(github.event.pull_request.labels.*.name, 'approved')) + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 + with: + comment-id: ${{ steps.fc_warning.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + > [!WARNING] + > This Pull Request modifies the SDBA module. + **The SDBA module is gradually being deprecated in favour of the `xsdba` package.** + **Any changes to `xclim.sdba` should be made in https://github.com/Ouranosinc/xsdba** + edit-mode: replace + - name: Compare Versions + if: (!contains(github.event.pull_request.labels.*.name, 'approved')) + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + core.setFailed('Changes were made to `xclim.sdba`.') + - name: Find Note Comment + uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 + id: fc_note + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: This Pull Request modifies the SDBA module. + - name: Update Comment + if: | + contains(github.event.pull_request.labels.*.name, 'approved') + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 + with: + comment-id: ${{ steps.fc_note.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + > [!NOTE] + > This Pull Request modifies the SDBA module. + **The changes made here has been approved. Be sure to port any relevant changes to `xsdba`.** + reactions: | + hooray + edit-mode: append diff --git a/docs/api.rst b/docs/api.rst index 8064ff8dc..e589c9066 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -80,6 +80,12 @@ Units Handling Submodule SDBA Module =========== +.. warning:: + + The SDBA submodule is in the process of being split from `xclim` in order to better facilitate effective maintenance + of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. + For more information, please visit https://xsdba.readthedocs.io/en/latest/. + .. automodule:: xclim.sdba.adjustment :members: :exclude-members: BaseAdjustment @@ -215,6 +221,12 @@ Bootstrapping Algorithms for Indicators Submodule SDBA Utilities -------------- +.. warning:: + + The SDBA submodule is in the process of being split from `xclim` in order to better facilitate effective maintenance + of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. + For more information, please visit https://xsdba.readthedocs.io/en/latest/. + .. automodule:: xclim.sdba.base :members: :show-inheritance: diff --git a/src/xclim/sdba/__init__.py b/src/xclim/sdba/__init__.py index e0b03aa3c..47c08c88b 100644 --- a/src/xclim/sdba/__init__.py +++ b/src/xclim/sdba/__init__.py @@ -2,15 +2,30 @@ ============== SDBA submodule ============== + +.. warning:: + + The SDBA submodule is in the process of being split from `xclim` in order to better facilitate effective maintenance + of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. + For more information, please visit https://xsdba.readthedocs.io/en/latest/. """ from __future__ import annotations +import warnings + from . import adjustment, detrending, measures, processing, properties, utils from .adjustment import * from .base import Grouper from .processing import stack_variables, unstack_variables +warnings.warn( + "The SDBA module is in the process of being split from 'xclim' in order to better facilitate effective maintenance " + "of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future." + "For more information, please visit https://xsdba.readthedocs.io/en/latest/.", + FutureWarning, +) + # TODO: ISIMIP ? Used for precip freq adjustment in biasCorrection.R # Hempel, S., Frieler, K., Warszawski, L., Schewe, J., & Piontek, F. (2013). A trend-preserving bias correction – # The ISI-MIP approach. Earth System Dynamics, 4(2), 219–236. https://doi.org/10.5194/esd-4-219-2013 From 3b425aeae024e3add799986809debb798d9a5546 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 11 Feb 2025 17:14:01 -0500 Subject: [PATCH 2/6] update CHANGELOG.rst, fix wording --- .github/workflows/sdba-warning.yml | 4 ++-- CHANGELOG.rst | 2 ++ docs/api.rst | 4 ++-- src/xclim/sdba/__init__.py | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sdba-warning.yml b/.github/workflows/sdba-warning.yml index 042557e8b..db8f5ed3a 100644 --- a/.github/workflows/sdba-warning.yml +++ b/.github/workflows/sdba-warning.yml @@ -1,4 +1,4 @@ -name: Workflow Changes Warnings +name: SDBA Changes Warnings on: # Note: potential security risk from this action using pull_request_target. @@ -52,7 +52,7 @@ jobs: **The SDBA module is gradually being deprecated in favour of the `xsdba` package.** **Any changes to `xclim.sdba` should be made in https://github.com/Ouranosinc/xsdba** edit-mode: replace - - name: Compare Versions + - name: Fail Workflow if: (!contains(github.event.pull_request.labels.*.name, 'approved')) uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1e61742b7..f975ed0e1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,7 @@ Announcements ^^^^^^^^^^^^^ * `xclim` now officially supports Python 3.13 (using `numba` v0.61.0). (:issue:`2022`, :pull:`2054`). * `xclim` version 0.55.0 will be the last version to support Python 3.10. The next version will require Python 3.11 or higher. (:pull:`2054`). +* `xclim.sdba` is in the process of being split into a separate package, `xsdba `_, to help with the maintenance of the codebase as well as better support new SDBA functionality. Feature additions to the `xclim.sdba` module will no longer be accepted and should be made instead to `xsdba`. The developers aim to ensure a high level of interoperability between `xclim` and `xsdba` so that users are minimally impacted; A migration guide will be made available in a future release. (:issue:`1948`, :issue:`2074`, :pull:`2073). New indicators ^^^^^^^^^^^^^^ @@ -38,6 +39,7 @@ Internal changes - Objects are initialized with their options and then called with the data, input frequency, target frequency and indexer. - Subclasses receive non-resampled DataArray in their ``is_missing`` methods. - ``MissingWMO`` now uses ``xclim.indices.helpers.resample_map`` which should greatly improve performance in a dask context. +* `xclim.sdba` now emits a `FutureWarning` on import to inform users that the submodule is being deprecated. (:pull:`2073). Bug fixes ^^^^^^^^^ diff --git a/docs/api.rst b/docs/api.rst index e589c9066..8f5ce29bf 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -82,7 +82,7 @@ SDBA Module .. warning:: - The SDBA submodule is in the process of being split from `xclim` in order to better facilitate effective maintenance + The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. @@ -223,7 +223,7 @@ SDBA Utilities .. warning:: - The SDBA submodule is in the process of being split from `xclim` in order to better facilitate effective maintenance + The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. diff --git a/src/xclim/sdba/__init__.py b/src/xclim/sdba/__init__.py index 47c08c88b..18cbeca33 100644 --- a/src/xclim/sdba/__init__.py +++ b/src/xclim/sdba/__init__.py @@ -5,7 +5,7 @@ .. warning:: - The SDBA submodule is in the process of being split from `xclim` in order to better facilitate effective maintenance + The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. """ @@ -20,7 +20,7 @@ from .processing import stack_variables, unstack_variables warnings.warn( - "The SDBA module is in the process of being split from 'xclim' in order to better facilitate effective maintenance " + "The SDBA module is in the process of being split from 'xclim' in order to facilitate effective maintenance " "of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future." "For more information, please visit https://xsdba.readthedocs.io/en/latest/.", FutureWarning, From 66d3e637ac8648b3d26cc6e6d386ce5f1558fda5 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 11 Feb 2025 17:40:24 -0500 Subject: [PATCH 3/6] fix typos --- CHANGELOG.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f975ed0e1..6f910d44f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,7 +14,7 @@ Announcements ^^^^^^^^^^^^^ * `xclim` now officially supports Python 3.13 (using `numba` v0.61.0). (:issue:`2022`, :pull:`2054`). * `xclim` version 0.55.0 will be the last version to support Python 3.10. The next version will require Python 3.11 or higher. (:pull:`2054`). -* `xclim.sdba` is in the process of being split into a separate package, `xsdba `_, to help with the maintenance of the codebase as well as better support new SDBA functionality. Feature additions to the `xclim.sdba` module will no longer be accepted and should be made instead to `xsdba`. The developers aim to ensure a high level of interoperability between `xclim` and `xsdba` so that users are minimally impacted; A migration guide will be made available in a future release. (:issue:`1948`, :issue:`2074`, :pull:`2073). +* `xclim.sdba` is in the process of being split into a separate package, `xsdba `_, to help with the maintenance of the codebase as well as better support new SDBA functionality. Feature additions to the `xclim.sdba` module will no longer be accepted and should be made instead to `xsdba`. The developers aim to ensure a high level of interoperability between `xclim` and `xsdba` so that users are minimally impacted; A migration guide will be made available in a future release. (:issue:`1948`, :issue:`2074`, :pull:`2073`). New indicators ^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ Internal changes - Objects are initialized with their options and then called with the data, input frequency, target frequency and indexer. - Subclasses receive non-resampled DataArray in their ``is_missing`` methods. - ``MissingWMO`` now uses ``xclim.indices.helpers.resample_map`` which should greatly improve performance in a dask context. -* `xclim.sdba` now emits a `FutureWarning` on import to inform users that the submodule is being deprecated. (:pull:`2073). +* `xclim.sdba` now emits a `FutureWarning` on import to inform users that the submodule is being deprecated. (:pull:`2073`). Bug fixes ^^^^^^^^^ From 348b5da83ea1f76458c843993d1b0368a3f5a233 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:36:44 -0500 Subject: [PATCH 4/6] Warn of changes, not deprecation --- CHANGELOG.rst | 2 +- docs/api.rst | 4 ++-- src/xclim/sdba/__init__.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 74989c58d..e7a9cfaca 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,7 +14,7 @@ Announcements ^^^^^^^^^^^^^ * `xclim` now officially supports Python 3.13 (using `numba` v0.61.0). (:issue:`2022`, :pull:`2054`). * `xclim` version 0.55.0 will be the last version to support Python 3.10. The next version will require Python 3.11 or higher. (:pull:`2054`). -* `xclim.sdba` is in the process of being split into a separate package, `xsdba `_, to help with the maintenance of the codebase as well as better support new SDBA functionality. Feature additions to the `xclim.sdba` module will no longer be accepted and should be made instead to `xsdba`. The developers aim to ensure a high level of interoperability between `xclim` and `xsdba` so that users are minimally impacted; A migration guide will be made available in a future release. (:issue:`1948`, :issue:`2074`, :pull:`2073`). +* `xclim.sdba` is in the process of being split into a separate package (`xsdba `_) to help with the maintenance of the codebase as well as better support new SDBA functionality. Feature additions to the `xclim.sdba` module will no longer be accepted and should be made instead to `xsdba`. The developers aim to ensure a high level of interoperability between `xclim` and `xsdba` so that users are minimally impacted; A migration guide will be made available in a future release. (:issue:`1948`, :issue:`2074`, :pull:`2073`). New indicators ^^^^^^^^^^^^^^ diff --git a/docs/api.rst b/docs/api.rst index 8f5ce29bf..08b469622 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -83,7 +83,7 @@ SDBA Module .. warning:: The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance - of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. + of the SDBA utilities as well as speed up imports in `xclim`. `xclim.sdba` functionality will change in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. .. automodule:: xclim.sdba.adjustment @@ -224,7 +224,7 @@ SDBA Utilities .. warning:: The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance - of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. + of the SDBA utilities as well as speed up imports in `xclim`. `xclim.sdba` functionality will change in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. .. automodule:: xclim.sdba.base diff --git a/src/xclim/sdba/__init__.py b/src/xclim/sdba/__init__.py index 18cbeca33..0c054dce0 100644 --- a/src/xclim/sdba/__init__.py +++ b/src/xclim/sdba/__init__.py @@ -6,7 +6,7 @@ .. warning:: The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance - of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future. + of the SDBA utilities as well as speed up imports in `xclim`. `xclim.sdba` functionality will change in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. """ @@ -21,7 +21,7 @@ warnings.warn( "The SDBA module is in the process of being split from 'xclim' in order to facilitate effective maintenance " - "of the SDBA utilities as well as speed up imports in `xclim`. The `xclim.sdba` API will be deprecated in the future." + "of the SDBA utilities as well as speed up imports in `xclim`. `xclim.sdba` functionality will change in the future. " "For more information, please visit https://xsdba.readthedocs.io/en/latest/.", FutureWarning, ) From 71c0cbd1aac8f4cb79f9a96d011fafb40a29fc9b Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:59:41 -0500 Subject: [PATCH 5/6] address review comments --- docs/api.rst | 8 ++++---- src/xclim/sdba/__init__.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 08b469622..14d5c3c2d 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -82,8 +82,8 @@ SDBA Module .. warning:: - The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance - of the SDBA utilities as well as speed up imports in `xclim`. `xclim.sdba` functionality will change in the future. + The SDBA submodule is in the process of being split from `xclim` in order to facilitate development and effective + maintenance of the SDBA utilities. The `xclim.sdba` functionality will change in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. .. automodule:: xclim.sdba.adjustment @@ -223,8 +223,8 @@ SDBA Utilities .. warning:: - The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance - of the SDBA utilities as well as speed up imports in `xclim`. `xclim.sdba` functionality will change in the future. + The SDBA submodule is in the process of being split from `xclim` in order to facilitate development and effective + maintenance of the SDBA utilities. The `xclim.sdba` functionality will change in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. .. automodule:: xclim.sdba.base diff --git a/src/xclim/sdba/__init__.py b/src/xclim/sdba/__init__.py index 0c054dce0..e63823fd1 100644 --- a/src/xclim/sdba/__init__.py +++ b/src/xclim/sdba/__init__.py @@ -5,8 +5,8 @@ .. warning:: - The SDBA submodule is in the process of being split from `xclim` in order to facilitate effective maintenance - of the SDBA utilities as well as speed up imports in `xclim`. `xclim.sdba` functionality will change in the future. + The SDBA submodule is in the process of being split from `xclim` in order to facilitate development and effective + maintenance of the SDBA utilities. The `xclim.sdba` functionality will change in the future. For more information, please visit https://xsdba.readthedocs.io/en/latest/. """ @@ -20,8 +20,8 @@ from .processing import stack_variables, unstack_variables warnings.warn( - "The SDBA module is in the process of being split from 'xclim' in order to facilitate effective maintenance " - "of the SDBA utilities as well as speed up imports in `xclim`. `xclim.sdba` functionality will change in the future. " + "The SDBA submodule is in the process of being split from `xclim` in order to facilitate development and effective " + "maintenance of the SDBA utilities. The `xclim.sdba` functionality will change in the future. " "For more information, please visit https://xsdba.readthedocs.io/en/latest/.", FutureWarning, ) From a61664d80e244819a60a61a70e942101c01db10c Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Feb 2025 14:15:35 -0500 Subject: [PATCH 6/6] typo fix --- .github/workflows/sdba-warning.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sdba-warning.yml b/.github/workflows/sdba-warning.yml index db8f5ed3a..2da2905d2 100644 --- a/.github/workflows/sdba-warning.yml +++ b/.github/workflows/sdba-warning.yml @@ -75,7 +75,7 @@ jobs: body: | > [!NOTE] > This Pull Request modifies the SDBA module. - **The changes made here has been approved. Be sure to port any relevant changes to `xsdba`.** + **The changes made here have been approved. Be sure to port any relevant changes to `xsdba`.** reactions: | hooray edit-mode: append