Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use caching to speed up testdata fetching, fix upstream builds, scipy suggestions #1906

Merged
merged 31 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5da4181
use caching to speed up testdata fetching
Zeitsperre Sep 5, 2024
e6f6977
fix expression
Zeitsperre Sep 5, 2024
539b8b8
add caching to preliminary build
Zeitsperre Sep 5, 2024
18ec3fe
update CHANGELOG.rst and more caching
Zeitsperre Sep 5, 2024
a95ab63
adjustments
Zeitsperre Sep 5, 2024
8a01a04
more streamlined caching
Zeitsperre Sep 5, 2024
51d377a
better naming
Zeitsperre Sep 5, 2024
805b43e
final adjustments
Zeitsperre Sep 5, 2024
4b6fb1f
use coveralls app
Zeitsperre Sep 6, 2024
61686df
use caching in upstream.yml
Zeitsperre Sep 6, 2024
b087eff
fix silently failing upstream dependency installation step
Zeitsperre Sep 6, 2024
e9adfe4
replace isort with `ruff`, add pygrep-hooks and mdformat, update ruff…
Zeitsperre Sep 9, 2024
ff8f980
update pre-commit config
Zeitsperre Sep 9, 2024
8623cd6
update markdown files
Zeitsperre Sep 9, 2024
6d45285
fix markdown formatting rules
Zeitsperre Sep 9, 2024
30e7380
fix remaining non-code files
Zeitsperre Sep 9, 2024
2941dca
adjust linting rules, run pre-commit fixes, add more error information
Zeitsperre Sep 9, 2024
c32cb03
do not reformat publish-mastodon-template.md
Zeitsperre Sep 9, 2024
97167f0
use dependency grouping to reduce number of PRs opened every week
Zeitsperre Sep 9, 2024
f053258
set xfail_strict for tests
Zeitsperre Sep 9, 2024
2e4a42b
adjust tests
Zeitsperre Sep 10, 2024
a65ecd1
no more verbose testing
Zeitsperre Sep 10, 2024
b3c48ec
Merge branch 'main' into use-more-caching
Zeitsperre Sep 13, 2024
b6b6cc4
Merge branch 'use-more-caching' into repo-suggestions
Zeitsperre Sep 13, 2024
328ac6b
Merge branch 'main' into use-more-caching
Zeitsperre Sep 16, 2024
c382be1
Merge branch 'use-more-caching' into repo-suggestions
Zeitsperre Sep 17, 2024
b8b9cd7
fix test_amount2lwethickness
coxipi Sep 17, 2024
1140b7c
fix CHANGELOG.rst
Zeitsperre Sep 17, 2024
4c1cd39
update CHANGELOG.rst
Zeitsperre Sep 17, 2024
167dfad
Apply SciPy-like repository suggestions (#1910)
Zeitsperre Sep 17, 2024
004b95a
Merge branch 'main' into use-more-caching
Zeitsperre Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 66 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ jobs:
(github.event_name == 'push')
strategy:
matrix:
python-version:
- "3.9"
python-version: [ "3.9" ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
Expand All @@ -58,9 +57,17 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Environment Caching
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
${{ matrix.testdata-cache }}
.tox
key: ${{ runner.os }}-xclim-testdata-${{ env.XCLIM_TESTDATA_BRANCH }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}-lint
- name: Run pylint
run: |
python -m pylint --rcfile=.pylintrc.toml --disable=import-error --exit-zero xclim
Expand All @@ -69,13 +76,14 @@ jobs:
python -m tox -e lint

test-preliminary:
name: Python${{ matrix.python-version }} (ubuntu-latest)
name: Python${{ matrix.python-version }} (${{ matrix.os }})
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.9"
os: [ 'ubuntu-latest' ]
python-version: [ "3.9" ]
testdata-cache: [ '~/.cache/xclim-testdata' ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
Expand All @@ -95,9 +103,17 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Environment Caching
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
${{ matrix.testdata-cache }}
.tox
key: ${{ runner.os }}-xclim-testdata-${{ env.XCLIM_TESTDATA_BRANCH }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}-Python${{ matrix.python-version }}
- name: Test with tox
run: |
python -m tox -- -m 'not slow'
Expand All @@ -118,39 +134,47 @@ jobs:
matrix:
include:
# Linux builds
- os: ubuntu-latest
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: -m 'not slow'
python-version: "3.10"
tox-env: standard
- os: ubuntu-latest
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: -m 'not slow'
python-version: "3.11"
tox-env: standard
- os: ubuntu-latest
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: -m 'not slow'
python-version: "3.12"
tox-env: standard
# Windows builds
- os: windows-latest
- os: 'windows-latest'
testdata-cache: 'C:\Users\runneradmin\AppData\Local\xclim-testdata\xclim-testdata\Cache'
markers: -m 'not slow'
python-version: "3.9"
tox-env: py39-coverage-prefetch # Test data prefetch is needed for Windows
# macOS builds
- os: macos-latest
python-version: "3.10"
- os: 'macos-latest'
testdata-cache: '~/Library/Caches/xclim-testdata'
markers: '' # Slow tests
python-version: "3.10"
tox-env: py310-coverage-extras
# Specialized tests
- os: ubuntu-latest
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: -m 'not requires_internet and not slow'
python-version: "3.9"
tox-env: py39-coverage-offline-prefetch
- os: ubuntu-latest
markers: ''
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: '' # No markers for notebooks
python-version: "3.10"
tox-env: notebooks
- os: ubuntu-latest
markers: ''
- os: 'ubuntu-latest'
testdata-cache: '~/.cache/xclim-testdata'
markers: '' # No markers for doctests
python-version: "3.12"
tox-env: doctests
steps:
Expand Down Expand Up @@ -182,9 +206,19 @@ jobs:
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Environment Caching
# if prefetch is not in tox-env
if: contains(matrix.tox-env, 'prefetch') == false
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
${{ matrix.testdata-cache }}
.tox
key: ${{ runner.os }}-xclim-testdata-${{ env.XCLIM_TESTDATA_BRANCH }}-${{ hashFiles('pyproject.toml', 'tox.ini') }}-Python${{ matrix.python-version }}
- name: Test with tox
if: ${{ matrix.tox-env == 'standard' }}
run: |
Expand Down Expand Up @@ -212,8 +246,9 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
os: [ 'ubuntu-latest' ]
python-version: [ "3.9", "3.12" ]
testdata-cache: [ '~/.cache/xclim-testdata' ]
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -247,6 +282,12 @@ jobs:
- name: Micromamba version
run: |
echo "micromamba: $(micromamba --version)"
- name: Test Data Caching
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
${{ matrix.testdata-cache }}
key: ${{ runner.os }}-xclim-testdata-${{ env.XCLIM_TESTDATA_BRANCH }}-conda-${{ hashFiles('pyproject.toml', 'tox.ini') }}-Python${{ matrix.python-version }}
- name: Install xclim
run: |
python -m pip install --no-user --editable .
Expand Down Expand Up @@ -284,18 +325,13 @@ jobs:
- test-pypi
- test-conda
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
sparse-checkout: |
CI/requirements_ci.txt
- 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 }}
disable-sudo: true
egress-policy: audit
- name: Coveralls Finished
uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 # v2.3.0
with:
parallel-finished: true
13 changes: 10 additions & 3 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
python-version: [ "3.12" ]
testdata-cache: [ '~/.cache/xclim-testdata' ]
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -66,8 +66,8 @@ jobs:
create-args: >-
eigen
pybind11
python=${{ matrix.python-version }}
pytest-reportlog
python=${{ matrix.python-version }}
- name: Micromamba version
run: |
echo "micromamba: $(micromamba --version)"
Expand All @@ -84,6 +84,12 @@ jobs:
micromamba list
xclim show_version_info
python -m pip check || true
- name: Test Data Caching
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
${{ matrix.testdata-cache }}
key: ${{ runner.os }}-xclim-testdata-upstream-${{ hashFiles('pyproject.toml', 'tox.ini') }}
- name: Run Tests
if: success()
id: status
Expand All @@ -97,4 +103,5 @@ jobs:
&& github.repository_owner == 'Ouranosinc'
uses: xarray-contrib/issue-from-pytest-log@f94477e45ef40e4403d7585ba639a9a3bcc53d43 # v1.3.0
with:
issue-title: "⚠️ Nightly upstream-dev CI failed for Python${{ matrix.python-version }} ⚠️"
log-path: output-${{ matrix.python-version }}-log.jsonl
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Internal changes
* ``xclim.core`` now uses absolute imports for clarity and some objects commonly used in the module have been moved to hidden submodules. (:issue:`1719`, :pull:`1881`).
* ``xclim.core.indicator.Parameter`` has a new attribute ``compute_name`` while ``xclim.core.indicator.Indicator`` lost its ``_variable_mapping``. The translation from parameter (and variable) names in the indicator to the names on the compute function is handled by ``Indicator._get_compute_args``. (:pull:`1885`).

CI changes
^^^^^^^^^^
* The `pip` cache, `tox` environments, and the `xclim-testdata` cache are now saved between workflow runs (using `actions/cache`) to reduce the time spent installing dependencies and downloading testing data. (:pull:`1906`).

v0.52.0 (2024-08-08)
--------------------
Contributors to this version: David Huard (:user:`huard`), Trevor James Smith (:user:`Zeitsperre`), Hui-Min Wang (:user:`Hem-W`), Éric Dupuis (:user:`coxipi`), Sarah Gammon (:user:`SarahG-579462`), Pascal Bourgault (:user:`aulemahal`), Juliette Lavoie (:user:`juliettelavoie`), Adrien Lamarche (:user:`LamAdr`).
Expand Down
1 change: 0 additions & 1 deletion CI/requirements_upstream.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
bottleneck @ git+https://github.com/pydata/bottleneck.git@master
cftime @ git+https://github.com/Unidata/cftime.git@master
flox @ git+https://github.com/xarray-contrib/flox.git@main
numba @ git+https://github.com/numba/numba.git@main
numpy @ git+https://github.com/numpy/numpy.git@main
xarray @ git+https://github.com/pydata/xarray.git@main
Loading