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 all 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
12 changes: 8 additions & 4 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
* xclim version:
* Python version:
* Operating System:
- xclim version:
- Python version:
- Operating System:

### Description

<!--Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.-->


### What I Did

<!--Paste the command(s) you ran and the output.
If there was a crash, please include the traceback below.-->

```
$ pip install foo --bar
```

### What I Received

<!--Paste the output or the stack trace of the problem you experienced here.-->

```
Traceback (most recent call last):
File "/path/to/file/script.py", line 3326, in run_code
Expand Down
14 changes: 10 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
interval: weekly
time: '12:00'
open-pull-requests-limit: 5
groups:
actions:
patterns:
- "*"

- package-ecosystem: pip
directory: /
schedule:
interval: daily
interval: weekly
time: '12:00'
open-pull-requests-limit: 5
groups:
python:
patterns:
- "*"
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
2 changes: 1 addition & 1 deletion .github/workflows/publish-mastodon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
id: render_template
uses: chuhlomin/render-template@807354a04d9300c9c2ac177c0aa41556c92b3f75 # v1.10
with:
template: .github/publish-mastodon.template.md
template: .github/publish-mastodon-template.md
vars: |
version: ${{ env.version }}

Expand Down
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
29 changes: 20 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: '.ipynb|.github/publish-mastodon.template.md'
exclude: '.ipynb|.github/publish-mastodon-template.md'
- id: check-json
- id: check-toml
- id: check-yaml
Expand All @@ -36,15 +36,11 @@ repos:
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
hooks:
- id: ruff
args: [ '--fix' ]
args: [ '--fix', '--show-fixes' ]
- repo: https://github.com/pylint-dev/pylint
rev: v3.2.7
hooks:
Expand All @@ -68,20 +64,35 @@ repos:
additional_dependencies: [ 'pyupgrade==3.16.0' ]
- id: nbqa-black
additional_dependencies: [ 'black==24.4.2' ]
- id: nbqa-isort
additional_dependencies: [ 'isort==5.13.2' ]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
files: '.ipynb'
args: [ '--extra-keys', 'metadata.kernelspec' ]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
# - id: python-check-blanket-noqa
# - id: python-check-blanket-type-ignore
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
exclude: '.github/\w+.md|.github/publish-mastodon-template.md|docs/paper/paper.md'
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [ 'black==24.4.2' ]
additional_dependencies: [ 'black==24.8.0' ]
exclude: '(xclim/indices/__init__.py|docs/installation.rst)'
- id: blackdoc-autoupdate-black
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
Expand Down
Loading
Loading