Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 4 additions & 10 deletions .github/workflows/benchmarks_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ jobs:
IRIS_TEST_DATA_PATH: benchmarks/iris-test-data
IRIS_TEST_DATA_VERSION: "2.28"
# Lets us manually bump the cache to rebuild
ENV_CACHE_BUILD: "0"
TEST_DATA_CACHE_BUILD: "2"

steps:
Expand All @@ -79,15 +78,10 @@ jobs:
- name: Install run dependencies
run: pip install asv nox!=2025.05.01

- name: Cache environment directories
id: cache-env-dir
uses: actions/cache@v4
with:
path: |
.nox
benchmarks/.asv/env
$CONDA/pkgs
key: ${{ runner.os }}-${{ hashFiles('requirements/') }}-${{ env.ENV_CACHE_BUILD }}
# Note: this cache is shared across workflows, so sets its own cache period
# and build number.
- name: Cache Conda package directory
uses: ./.github/workflows/composite/conda-pkg-cache

- name: Cache test data directory
id: cache-test-data
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/benchmarks_validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ jobs:
validate:
runs-on: ubuntu-latest

env:
# Lets us manually bump the cache to rebuild
ENV_CACHE_BUILD: "0"

steps:
- name: Checkout repo
uses: actions/checkout@v5
Expand All @@ -34,15 +30,10 @@ jobs:
- name: Install run dependencies
run: pip install asv nox!=2025.05.01

- name: Cache environment directories
id: cache-env-dir
uses: actions/cache@v4
with:
path: |
.nox
benchmarks/.asv/env
$CONDA/pkgs
key: ${{ runner.os }}-${{ hashFiles('requirements/') }}-${{ env.ENV_CACHE_BUILD }}
# Note: this cache is shared across workflows, so sets its own cache period
# and build number.
- name: Cache Conda package directory
uses: ./.github/workflows/composite/conda-pkg-cache

- name: Validate setup
run: nox -s benchmarks -- validate
22 changes: 5 additions & 17 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ jobs:
env_name: ${{ env.ENV_NAME }}
version: ${{ env.IRIS_TEST_DATA_VERSION }}

# Note: this cache is shared across workflows, so sets its own cache period
# and build number.
- name: "conda package cache"
uses: ./.github/workflows/composite/conda-pkg-cache
with:
cache_build: 6
cache_period: ${{ env.CACHE_PERIOD }}
env_name: ${{ env.ENV_NAME }}
python_version: ${{ matrix.python-version }}

- name: "conda install"
uses: conda-incubator/setup-miniconda@v3
Expand All @@ -88,13 +88,8 @@ jobs:
activate-environment: ${{ env.ENV_NAME }}
auto-update-conda: false

- name: "conda environment cache"
uses: ./.github/workflows/composite/conda-env-cache
with:
cache_build: 6
cache_period: ${{ env.CACHE_PERIOD }}
env_name: ${{ env.ENV_NAME }}
install_packages: "cartopy nox pip"
- name: "install cartopy + nox + pip"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could stand some improvement. The wheels job always finishes first and populates the cache. When the tests job - this one - finishes, it does not overwrite the cache. For the top level Nox environment, the Python version is not controlled, so the dependency stack will often be for a different Python version than what is in the cache, leading to lots of new downloads.

Solutions

  • Make the Nox environment use matrix.python-version, so that the Cartopy dependency stack comes from the cache.
  • Give the tests workflow 'control' of the cache, having wheels etc only use the cache but not populate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should benchmarking also be using the Cartopy cache?

run: conda install --quiet --name ${{ env.ENV_NAME }} cartopy nox pip

- name: "conda info"
run: |
Expand All @@ -108,13 +103,6 @@ jobs:
cache_period: ${{ env.CACHE_PERIOD }}
env_name: ${{ env.ENV_NAME }}

- name: "nox cache"
uses: ./.github/workflows/composite/nox-cache
with:
cache_build: 6
env_name: ${{ env.ENV_NAME }}
lock_file: ${{ env.LOCK_FILE }}

# TODO: drop use of site.cfg and explicit use of mplrc
- name: "iris configure"
env:
Expand Down
22 changes: 5 additions & 17 deletions .github/workflows/ci-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ jobs:
echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV}
echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}

# Note: this cache is shared across workflows, so sets its own cache period
# and build number.
- name: "conda package cache"
uses: ./.github/workflows/composite/conda-pkg-cache
with:
cache_build: 0
cache_period: ${{ env.CACHE_PERIOD }}
env_name: ${{ env.ENV_NAME }}
python_version: ${{ matrix.python-version }}

- name: "conda install"
uses: conda-incubator/setup-miniconda@v3
Expand All @@ -90,20 +90,8 @@ jobs:
auto-update-conda: false
use-only-tar-bz2: true

- name: "conda environment cache"
uses: ./.github/workflows/composite/conda-env-cache
with:
cache_build: 0
cache_period: ${{ env.CACHE_PERIOD }}
env_name: ${{ env.ENV_NAME }}
install_packages: "nox pip"

- name: "nox cache"
uses: ./.github/workflows/composite/nox-cache
with:
cache_build: 1
env_name: ${{ env.ENV_NAME }}
lock_file: ${{ env.LOCK_FILE }}
- name: "install nox + pip"
run: conda install --quiet --name ${{ env.ENV_NAME }} nox pip

- name: "nox install and test wheel"
env:
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/composite/conda-env-cache/action.yml

This file was deleted.

44 changes: 32 additions & 12 deletions .github/workflows/composite/conda-pkg-cache/action.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
name: "conda-pkg-cache"
description: "cache the conda environment packages"
description: "standardise conda package cache to ~/conda_pkgs_dir and cache across workflow runs"

inputs:
cache_build:
description: "conda environment cache build number"
python_version:
description: "conda package cache python version"
required: false
default: "0"
cache_period:
description: "conda environment cache timestamp"
required: true
env_name:
description: "environment name"
required: true
default: "3.13"

runs:
using: "composite"
steps:
- uses: actions/cache@v4
- id: set-cache-period
shell: bash
env:
# Maximum cache period (in weeks) before forcing a cache refresh..
CACHE_WEEKS: 2
run: echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> $GITHUB_OUTPUT

- id: define-cache-key
shell: bash
env:
# Lets us manually bump the cache to rebuild.
CACHE_BUILD: "0"
run: |
OS="${{ runner.os }}"
PERIOD="${{ steps.set-cache-period.outputs.CACHE_PERIOD }}"
BUILD="${{ env.CACHE_BUILD }}"
PY="${{ inputs.python_version }}"
REQ="${{ hashFiles('requirements/locks/**') }}"
CACHE_KEY="conda_pkgs_dir-${OS}-p${PERIOD}-b${BUILD}-py${PY}-${REQ}"
echo "CACHE_KEY=$CACHE_KEY" >> $GITHUB_ENV

- id: set-pkg-dir
shell: bash
run: conda config --add pkgs_dirs ~/conda_pkgs_dir

- id: conda-pkg-cache
uses: actions/cache@v4
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-pkgs-${{ inputs.env_name }}-p${{ inputs.cache_period }}-b${{ inputs.cache_build }}
key: ${{ env.CACHE_KEY }}
22 changes: 0 additions & 22 deletions .github/workflows/composite/nox-cache/action.yml

This file was deleted.

2 changes: 2 additions & 0 deletions lib/iris/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_python_versions():
nox_file = root_dir / "noxfile.py"
ci_wheels_file = workflows_dir / "ci-wheels.yml"
ci_tests_file = workflows_dir / "ci-tests.yml"
ci_pkg_cache_file = workflows_dir / "composite" / "conda-pkg-cache" / "action.yml"
benchmark_runner_file = benchmarks_dir / "bm_runner.py"

text_searches: List[Tuple[Path, str]] = [
Expand All @@ -107,6 +108,7 @@ def test_python_versions():
f'{" " * 8}session: ["doctest", "gallery"]'
),
),
(ci_pkg_cache_file, f'default: "{latest_supported}"'),
(benchmark_runner_file, f'python_version = "{latest_supported}"'),
]

Expand Down
Loading