Skip to content

Commit 6dd0ad5

Browse files
authored
Merge pull request #6430 from trexfeathers/cherry-pick-312
Changes needed for v3.12.1
2 parents 0ec821d + 6df2d64 commit 6dd0ad5

File tree

27 files changed

+594
-473
lines changed

27 files changed

+594
-473
lines changed

.github/workflows/benchmarks_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ jobs:
8080
- name: Post reports
8181
env:
8282
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83-
run: python benchmarks/bm_runner.py _gh_post
83+
run: benchmarks/bm_runner.py _gh_post

.github/workflows/benchmarks_run.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ on:
2121

2222
jobs:
2323
pre-checks:
24+
# This workflow supports two different scenarios (overnight and branch).
25+
# The pre-checks job determines which scenario is being run.
2426
runs-on: ubuntu-latest
2527
if: github.repository == 'SciTools/iris'
2628
outputs:
@@ -36,9 +38,11 @@ jobs:
3638
# SEE ALSO .github/labeler.yml .
3739
paths: requirements/locks/*.lock setup.py
3840
- id: overnight
41+
name: Check overnight scenario
3942
if: github.event_name != 'pull_request'
4043
run: echo "check=true" >> "$GITHUB_OUTPUT"
4144
- id: branch
45+
name: Check branch scenario
4246
if: >
4347
github.event_name == 'pull_request'
4448
&&
@@ -67,7 +71,8 @@ jobs:
6771

6872
steps:
6973
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
70-
- uses: actions/checkout@v4
74+
- name: Checkout repo
75+
uses: actions/checkout@v4
7176
with:
7277
fetch-depth: 0
7378

@@ -107,6 +112,8 @@ jobs:
107112
echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV
108113
109114
- name: Benchmark this pull request
115+
# If the 'branch' condition(s) are met: use the bm_runner to compare
116+
# the proposed merge with the base branch.
110117
if: needs.pre-checks.outputs.branch == 'true'
111118
env:
112119
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -115,10 +122,14 @@ jobs:
115122
nox -s benchmarks -- branch origin/${{ github.base_ref }}
116123
117124
- name: Run overnight benchmarks
125+
# If the 'overnight' condition(s) are met: use the bm_runner to compare
126+
# each of the last 24 hours' commits to their parents.
118127
id: overnight
119128
if: needs.pre-checks.outputs.overnight == 'true'
120129
env:
121130
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131+
# The first_commit argument allows a custom starting point - useful
132+
# for manual re-running.
122133
run: |
123134
first_commit=${{ inputs.first_commit }}
124135
if [ "$first_commit" == "" ]
@@ -132,6 +143,8 @@ jobs:
132143
fi
133144
134145
- name: Warn of failure
146+
# The overnight run is not on a pull request, so a failure could go
147+
# unnoticed without being actively advertised.
135148
if: >
136149
failure() &&
137150
steps.overnight.outcome == 'failure'
@@ -143,13 +156,15 @@ jobs:
143156
gh issue create --title "$title" --body "$body" --label "Bot" --label "Type: Performance" --repo $GITHUB_REPOSITORY
144157
145158
- name: Upload any benchmark reports
159+
# Uploading enables more downstream processing e.g. posting a PR comment.
146160
if: success() || steps.overnight.outcome == 'failure'
147161
uses: actions/upload-artifact@v4
148162
with:
149163
name: benchmark_reports
150164
path: .github/workflows/benchmark_reports
151165

152166
- name: Archive asv results
167+
# Store the raw ASV database(s) to help manual investigations.
153168
if: ${{ always() }}
154169
uses: actions/upload-artifact@v4
155170
with:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Linkcheck
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "00 06 * * *"
7+
8+
jobs:
9+
linkChecker:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write # required for peter-evans/create-issue-from-file
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Link Checker
17+
id: lychee
18+
uses: lycheeverse/lychee-action@f613c4a64e50d792e0b31ec34bbcbba12263c6a6
19+
with:
20+
fail: false
21+
args: "--verbose './docs/**/*.rst' './docs/**/*.inc' './lib/**/*.py'"
22+
23+
- name: Create Issue From File
24+
if: steps.lychee.outputs.exit_code != 0
25+
uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd
26+
with:
27+
title: Link Checker Report
28+
content-filepath: ./lychee/out.md
29+
labels: "Bot, Type: Documentation, Type: Bug"
30+
31+
- name: Fail Workflow On Link Errors
32+
if: steps.lychee.outputs.exit_code != 0
33+
run:
34+
exit {{ steps.lychee.outputs.exit_code }}

.github/workflows/ci-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
matrix:
3737
os: ["ubuntu-latest"]
3838
python-version: ["3.13"]
39-
session: ["doctest", "gallery", "linkcheck"]
39+
session: ["doctest", "gallery"]
4040
include:
4141
- os: "ubuntu-latest"
4242
python-version: "3.13"

.lycheeignore

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# nonfunctional, found in some code examples
2+
file:///
3+
4+
# DEAD : legacy in various old whatsnews
5+
https://biggus.readthedocs.io
6+
7+
# unkown problem, works in browser : used in further_topics/ugrid/data_model
8+
https://doi.org/10.3390/jmse2010194
9+
10+
# DEAD, todo:remove, used in docs/src/userguide/plotting_a_cube.rst
11+
https://effbot.org
12+
13+
# nonfunctional, found in some code examples
14+
https://foo/
15+
16+
# DEAD, todo:remove, used in docs/src/further_topics/ugrid/data_model.rst
17+
https://ibm-design-language.eu-de.mybluemix.net/design/language/resources/color-library
18+
19+
# DEAD, legacy in whatsnew/1.4.rst
20+
https://geoport.whoi.edu/thredds/dodsC/bathy/gom15
21+
22+
# exist, but bad certificates
23+
https://georepository.com
24+
https://geoport.whoi.edu:80/thredds/
25+
26+
# catch (at least) github userids, of which many in whatsnews, too many --> "too many requests" failures
27+
https://github.com/[^/]*$
28+
29+
# nonfunctional example, used in docs/src/developers_guide/gitwash/development_workflow.rst
30+
https://github.com/your-user-name/iris
31+
32+
# problem with bad certificate (review sometime?)
33+
https://scitools.github.com/cartopy
34+
35+
# legacy ref in whatsnew/3.0.rst
36+
https://stickler-ci.com
37+
38+
# DEAD, todo:remove, used in lib/iris/symbols.py
39+
https://www.wmo.int/pages/prog/www/DPFS/documents/485_Vol_I_en_colour.pdf
40+
41+
# DEAD, todo:remove, used in docs/src/userguide/plotting_a_cube.rst
42+
# unkown problem, works in browser : used in docs/src/index.rst
43+
https://www.flaticon.com
44+
45+
# nonfunctional example, used in lib/iris/io/__init__.py
46+
https://www.thing.com
47+
48+
# DEAD, todo:remove, used in docs/src/userguide/plotting_a_cube.rst
49+
https://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_updates.html
50+
51+
# nonfunctional, found in some code examples
52+
https://www.somehost.com

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exclude .git-blame-ignore-revs
1111
exclude .git_archival.txt
1212
exclude .gitattributes
1313
exclude .gitignore
14+
exclude .lycheeignore
1415
exclude .mailmap
1516
exclude .pre-commit-config.yaml
1617
exclude .readthedocs.yml

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1414
| ⚙️ CI | [![ci-manifest](https://github.com/SciTools/iris/actions/workflows/ci-manifest.yml/badge.svg)](https://github.com/SciTools/iris/actions/workflows/ci-manifest.yml) [![ci-tests](https://github.com/SciTools/iris/actions/workflows/ci-tests.yml/badge.svg)](https://github.com/SciTools/iris/actions/workflows/ci-tests.yml) [![ci-wheels](https://github.com/SciTools/iris/actions/workflows/ci-wheels.yml/badge.svg)](https://github.com/SciTools/iris/actions/workflows/ci-wheels.yml) [![pre-commit](https://results.pre-commit.ci/badge/github/SciTools/iris/main.svg)](https://results.pre-commit.ci/latest/github/SciTools/iris/main) |
1515
| 💬 Community | [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-2.1-4baaaa.svg)](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) [![GH Discussions](https://img.shields.io/badge/github-discussions%20%F0%9F%92%AC-yellow?logo=github&logoColor=lightgrey)](https://github.com/SciTools/iris/discussions) [![twitter](https://img.shields.io/twitter/follow/scitools_iris?color=yellow&label=twitter%7Cscitools_iris&logo=twitter&style=plastic)](https://twitter.com/scitools_iris) |
16-
| 📖 Documentation | [![rtd](https://readthedocs.org/projects/scitools-iris/badge/?version=latest)](https://scitools-iris.readthedocs.io/en/latest/?badge=latest) |
16+
| 📖 Documentation | [![rtd](https://readthedocs.org/projects/scitools-iris/badge/?version=latest)](https://scitools-iris.readthedocs.io/en/latest/?badge=latest) [![Check Links](https://github.com/SciTools/iris/actions/workflows/ci-linkchecks.yml/badge.svg)](https://github.com/SciTools/iris/actions/workflows/ci-linkchecks.yml) |
1717
| 📈 Health | [![codecov](https://codecov.io/gh/SciTools/iris/branch/main/graph/badge.svg?token=0GeICSIF3g)](https://codecov.io/gh/SciTools/iris) |
1818
| ✨ Meta | [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![NEP29](https://raster.shields.io/badge/follows-NEP29-orange.png)](https://numpy.org/neps/nep-0029-deprecation_policy.html) [![license - bds-3-clause](https://img.shields.io/github/license/SciTools/iris)](https://github.com/SciTools/iris/blob/main/LICENSE) [![conda platform](https://img.shields.io/conda/pn/conda-forge/iris.svg)](https://anaconda.org/conda-forge/iris) |
1919
| 📦 Package | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.595182.svg)](https://doi.org/10.5281/zenodo.595182) [![conda-forge](https://img.shields.io/conda/vn/conda-forge/iris?color=orange&label=conda-forge&logo=conda-forge&logoColor=white)](https://anaconda.org/conda-forge/iris) [![pypi](https://img.shields.io/pypi/v/scitools-iris?color=orange&label=pypi&logo=python&logoColor=white)](https://pypi.org/project/scitools-iris/) [![pypi - python version](https://img.shields.io/pypi/pyversions/scitools-iris.svg?color=orange&logo=python&label=python&logoColor=white)](https://pypi.org/project/scitools-iris/) |

benchmarks/README.md

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Iris Performance Benchmarking
1+
# SciTools Performance Benchmarking
22

3-
Iris uses an [Airspeed Velocity](https://github.com/airspeed-velocity/asv)
3+
SciTools uses an [Airspeed Velocity](https://github.com/airspeed-velocity/asv)
44
(ASV) setup to benchmark performance. This is primarily designed to check for
55
performance shifts between commits using statistical analysis, but can also
66
be easily repurposed for manual comparative and scalability analyses.
@@ -21,25 +21,30 @@ by the PR. (This run is managed by
2121
[the aforementioned GitHub Action](../.github/workflows/benchmark.yml)).
2222

2323
To run locally: the **benchmark runner** provides conveniences for
24-
common benchmark setup and run tasks, including replicating the automated
25-
overnight run locally. This is accessed via the Nox `benchmarks` session - see
26-
`nox -s benchmarks -- --help` for detail (_see also:
27-
[bm_runner.py](./bm_runner.py)_). Alternatively you can directly run `asv ...`
28-
commands from this directory (you will still need Nox installed - see
29-
[Benchmark environments](#benchmark-environments)).
24+
common benchmark setup and run tasks, including replicating the benchmarking
25+
performed by GitHub Actions workflows. This can be accessed by:
26+
27+
- The Nox `benchmarks` session - (use
28+
`nox -s benchmarks -- --help` for details).
29+
- `benchmarks/bm_runner.py` (use the `--help` argument for details).
30+
- Directly running `asv` commands from the `benchmarks/` directory (check
31+
whether environment setup has any extra dependencies - see
32+
[Benchmark environments](#benchmark-environments)).
33+
34+
### Reducing run time
3035

3136
A significant portion of benchmark run time is environment management. Run-time
32-
can be reduced by placing the benchmark environment on the same file system as
33-
your
34-
[Conda package cache](https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#specify-pkg-directories),
35-
if it is not already. You can achieve this by either:
36-
37-
- Temporarily reconfiguring `ENV_PARENT` in `delegated_env_commands`
38-
in [asv.conf.json](asv.conf.json) to reference a location on the same file
39-
system as the Conda package cache.
37+
can be reduced by co-locating the benchmark environment and your
38+
[Conda package cache](https://docs.conda.io/projects/conda/en/latest/user-guide/configuration/custom-env-and-pkg-locations.html)
39+
on the same [file system](https://en.wikipedia.org/wiki/File_system), if they
40+
are not already. This can be done in several ways:
41+
42+
- Temporarily reconfiguring `env_parent` in
43+
[`_asv_delegated_abc`](_asv_delegated_abc.py) to reference a location on the same
44+
file system as the Conda package cache.
4045
- Using an alternative Conda package cache location during the benchmark run,
4146
e.g. via the `$CONDA_PKGS_DIRS` environment variable.
42-
- Moving your Iris repo to the same file system as the Conda package cache.
47+
- Moving your repo checkout to the same file system as the Conda package cache.
4348

4449
### Environment variables
4550

@@ -73,7 +78,8 @@ requirements will not be delayed by repeated environment setup - especially
7378
relevant given the [benchmark runner](bm_runner.py)'s use of
7479
[--interleave-rounds](https://asv.readthedocs.io/en/stable/commands.html?highlight=interleave-rounds#asv-run),
7580
or any time you know you will repeatedly benchmark the same commit. **NOTE:**
76-
Iris environments are large so this option can consume a lot of disk space.
81+
SciTools environments tend to large so this option can consume a lot of disk
82+
space.
7783

7884
## Writing benchmarks
7985

@@ -97,6 +103,7 @@ for manual investigations; and consider committing any useful benchmarks as
97103
[on-demand benchmarks](#on-demand-benchmarks) for future developers to use.
98104

99105
### Data generation
106+
100107
**Important:** be sure not to use the benchmarking environment to generate any
101108
test objects/files, as this environment changes with each commit being
102109
benchmarked, creating inconsistent benchmark 'conditions'. The
@@ -106,7 +113,7 @@ solution; read more detail there.
106113
### ASV re-run behaviour
107114

108115
Note that ASV re-runs a benchmark multiple times between its `setup()` routine.
109-
This is a problem for benchmarking certain Iris operations such as data
116+
This is a problem for benchmarking certain SciTools operations such as data
110117
realisation, since the data will no longer be lazy after the first run.
111118
Consider writing extra steps to restore objects' original state _within_ the
112119
benchmark itself.
@@ -117,10 +124,13 @@ maintain result accuracy this should be accompanied by increasing the number of
117124
repeats _between_ `setup()` calls using the `repeat` attribute.
118125
`warmup_time = 0` is also advisable since ASV performs independent re-runs to
119126
estimate run-time, and these will still be subject to the original problem.
127+
The `@disable_repeat_between_setup` decorator in
128+
[`benchmarks/__init__.py`](benchmarks/__init__.py) offers a convenience for
129+
all this.
120130

121131
### Custom benchmarks
122132

123-
Iris benchmarking implements custom benchmark types, such as a `tracemalloc`
133+
SciTools benchmarking implements custom benchmark types, such as a `tracemalloc`
124134
benchmark to measure memory growth. See [custom_bms/](./custom_bms) for more
125135
detail.
126136

@@ -131,10 +141,10 @@ limited available runtime and risk of false-positives. It remains useful for
131141
manual investigations).**
132142

133143
When comparing performance between commits/file-type/whatever it can be helpful
134-
to know if the differences exist in scaling or non-scaling parts of the Iris
135-
functionality in question. This can be done using a size parameter, setting
136-
one value to be as small as possible (e.g. a scalar `Cube`), and the other to
137-
be significantly larger (e.g. a 1000x1000 `Cube`). Performance differences
144+
to know if the differences exist in scaling or non-scaling parts of the
145+
operation under test. This can be done using a size parameter, setting
146+
one value to be as small as possible (e.g. a scalar value), and the other to
147+
be significantly larger (e.g. a 1000x1000 array). Performance differences
138148
might only be seen for the larger value, or the smaller, or both, getting you
139149
closer to the root cause.
140150

@@ -151,13 +161,15 @@ suites for the UK Met Office NG-VAT project.
151161
## Benchmark environments
152162

153163
We have disabled ASV's standard environment management, instead using an
154-
environment built using the same Nox scripts as Iris' test environments. This
155-
is done using ASV's plugin architecture - see
156-
[asv_delegated_conda.py](asv_delegated_conda.py) and the extra config items in
157-
[asv.conf.json](asv.conf.json).
164+
environment built using the same scripts that set up the package test
165+
environments.
166+
This is done using ASV's plugin architecture - see
167+
[`asv_delegated.py`](asv_delegated.py) and associated
168+
references in [`asv.conf.json`](asv.conf.json) (`environment_type` and
169+
`plugins`).
158170

159171
(ASV is written to control the environment(s) that benchmarks are run in -
160172
minimising external factors and also allowing it to compare between a matrix
161173
of dependencies (each in a separate environment). We have chosen to sacrifice
162174
these features in favour of testing each commit with its intended dependencies,
163-
controlled by Nox + lock-files).
175+
controlled by the test environment setup script(s)).

0 commit comments

Comments
 (0)