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

Support test data in benchmark workflows #4402

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2095a70
Support test data in benchmark workflows
Nov 8, 2021
02f59c5
Use existing test data for now to test
Nov 8, 2021
fb26b03
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 8, 2021
2d1b780
Set OVERRIDE_TEST_DATA_REPOSITORY properly
Nov 8, 2021
760fff1
Merge branch 'wjbenfold-ci-benchmarks-test-data' of github.com:wjbenf…
Nov 8, 2021
1acbea7
Manually set version number to mirror cirrus.yml
Nov 8, 2021
90cf420
Add licence to top of file
Nov 8, 2021
2d9b8f9
Specify absolute path of test data
Nov 8, 2021
b944fa7
Changes to regridding to remove unnecessary print statements
Nov 8, 2021
4f7462e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 8, 2021
30bd14a
Can't refer to environment variables in env block
Nov 9, 2021
b78ab47
Merge branch 'wjbenfold-ci-benchmarks-test-data' of github.com:wjbenf…
Nov 9, 2021
8bb1b46
Precommit checks benchmarks too
Nov 9, 2021
b0c856f
Set the env var for data location
Nov 9, 2021
a40a88c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 9, 2021
62b03f2
Add some logging to noxfile for now
Nov 9, 2021
c0a5a57
Merge branch 'wjbenfold-ci-benchmarks-test-data' of github.com:wjbenf…
Nov 9, 2021
0ab3125
Do we have the test data path set right?
Nov 9, 2021
0bd99af
Rearrange imports and fix logging
Nov 9, 2021
6e76a92
More logging because iris.config.TEST_DATA_DIR was None
Nov 9, 2021
4f55a5f
More logging and changed mv
Nov 9, 2021
f28cdd0
Revert logging changes
Nov 9, 2021
8f7032f
Enable caching
Nov 9, 2021
25f7d76
Update to use new test data
Nov 9, 2021
04ec65c
Trim out last bit of logging
Nov 9, 2021
dc666e6
Update cache test data directory
Nov 9, 2021
15521eb
Reprompt ci
Nov 9, 2021
c3ba131
Fix cache location
Nov 9, 2021
568bdff
Bit of logging to reprompt CI
Nov 9, 2021
f57768c
Remove that logging
Nov 9, 2021
43000d9
Added type hinting
Nov 10, 2021
abfd06a
Review changes
Nov 11, 2021
fdfba71
Prevent piping hiding benchmark failures
wjbenfold Nov 11, 2021
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
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env:
# Conda packages to be installed.
CONDA_CACHE_PACKAGES: "nox pip"
# Git commit hash for iris test data.
IRIS_TEST_DATA_VERSION: "2.4"
IRIS_TEST_DATA_VERSION: "2.5"
# Base directory for the iris-test-data.
IRIS_TEST_DATA_DIR: ${HOME}/iris-test-data

Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ jobs:
benchmark:
runs-on: ubuntu-latest

env:
IRIS_TEST_DATA_LOC_PATH: benchmarks
IRIS_TEST_DATA_PATH: benchmarks/iris-test-data
IRIS_TEST_DATA_VERSION: "2.5"
wjbenfold marked this conversation as resolved.
Show resolved Hide resolved
# Lets us manually bump the cache to rebuild
TEST_DATA_CACHE_BUILD: "2"

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
Expand Down Expand Up @@ -38,9 +45,31 @@ jobs:
key: ${{ runner.os }}-${{ github.sha }}
restore-keys: ${{ runner.os }}

- name: Cache test data directory
id: cache-test-data
uses: actions/cache@v2
with:
path: |
${{ env.IRIS_TEST_DATA_PATH }}
key:
test-data-${{ env.IRIS_TEST_DATA_VERSION }}-${{ env.TEST_DATA_CACHE_BUILD }}

- name: Fetch the test data
if: steps.cache-test-data.outputs.cache-hit != 'true'
run: |
wget --quiet https://github.com/SciTools/iris-test-data/archive/v${IRIS_TEST_DATA_VERSION}.zip -O iris-test-data.zip
unzip -q iris-test-data.zip
mkdir --parents ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_LOC_PATH}
mv iris-test-data-${IRIS_TEST_DATA_VERSION} ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}
- name: Set test data var
run: |
echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV
- name: Run CI benchmarks
run: |
mkdir --parents benchmarks/.asv
wjbenfold marked this conversation as resolved.
Show resolved Hide resolved
set -o pipefail
nox --session="benchmarks(ci compare)" | tee benchmarks/.asv/ci_compare.txt
- name: Archive asv results
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ files: |
noxfile\.py|
setup\.py|
docs\/.+\.py|
lib\/.+\.py
lib\/.+\.py|
benchmarks\/.+\.py
)
minimum_pre_commit_version: 1.21.0

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/metadata_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"""

from iris.common import (
metadata_manager_factory,
AncillaryVariableMetadata,
BaseMetadata,
CellMeasureMetadata,
CoordMetadata,
CubeMetadata,
DimCoordMetadata,
metadata_manager_factory,
)


Expand Down
1 change: 0 additions & 1 deletion benchmarks/benchmarks/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from iris import coords
from iris.common.metadata import AncillaryVariableMetadata


LONG_NAME = "air temperature"
STANDARD_NAME = "air_temperature"
VAR_NAME = "air_temp"
Expand Down
40 changes: 40 additions & 0 deletions benchmarks/benchmarks/regridding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright Iris contributors
#
# This file is part of Iris and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Regridding benchmark test
"""

# import iris tests first so that some things can be initialised before
# importing anything else
from iris import tests # isort:skip

import iris
from iris.analysis import AreaWeighted


class HorizontalChunkedRegridding:
def setup(self) -> None:
# Prepare a cube and a template

cube_file_path = tests.get_data_path(
["NetCDF", "regrid", "regrid_xyt.nc"]
)
self.cube = iris.load_cube(cube_file_path)

template_file_path = tests.get_data_path(
["NetCDF", "regrid", "regrid_template_global_latlon.nc"]
)
self.template_cube = iris.load_cube(template_file_path)

# Chunked data makes the regridder run repeatedly
self.cube.data = self.cube.lazy_data().rechunk((1, -1, -1))

def time_regrid_area_w(self) -> None:
# Regrid the cube onto the template.
out = self.cube.regrid(self.template_cube, AreaWeighted())
# Realise the data
out.data
4 changes: 2 additions & 2 deletions benchmarks/nox_asv_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
from shutil import copy2, copytree
from tempfile import TemporaryDirectory

from asv import util as asv_util
from asv.config import Config
from asv.console import log
from asv.environment import get_env_name
from asv.plugins.conda import Conda, _find_conda
from asv.repo import get_repo, Repo
from asv import util as asv_util
from asv.repo import Repo, get_repo


class NoxConda(Conda):
Expand Down