Skip to content

Commit 95b7ffe

Browse files
Provide a Nox benchmarks session as the recommended entry point (#5951)
* Provide a Nox benchmarks session as the recommended entry point. * What's New entry. * Full name of help argument. --------- Co-authored-by: stephenworsley <[email protected]>
1 parent 25b685c commit 95b7ffe

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

.github/workflows/benchmarks_run.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ jobs:
7171
with:
7272
fetch-depth: 0
7373

74-
- name: Install ASV & Nox
74+
- name: Install Nox
7575
run: |
76-
pip install asv nox
76+
pip install nox
7777
7878
- name: Cache environment directories
7979
id: cache-env-dir
@@ -112,7 +112,7 @@ jobs:
112112
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113113
PR_NUMBER: ${{ github.event.number }}
114114
run: |
115-
python benchmarks/bm_runner.py branch origin/${{ github.base_ref }}
115+
nox -s benchmarks -- branch origin/${{ github.base_ref }}
116116
117117
- name: Run overnight benchmarks
118118
id: overnight
@@ -128,7 +128,7 @@ jobs:
128128
129129
if [ "$first_commit" != "" ]
130130
then
131-
python benchmarks/bm_runner.py overnight $first_commit
131+
nox -s benchmarks -- overnight $first_commit
132132
fi
133133
134134
- name: Warn of failure

benchmarks/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ the PR's base branch, thus showing performance differences introduced
2020
by the PR. (This run is managed by
2121
[the aforementioned GitHub Action](../.github/workflows/benchmark.yml)).
2222

23-
`asv ...` commands must be run from this directory. You will need to have ASV
24-
installed, as well as Nox (see
25-
[Benchmark environments](#benchmark-environments)).
26-
27-
The benchmark runner ([bm_runner.py](./bm_runner.py)) provides conveniences for
23+
To run locally: the **benchmark runner** provides conveniences for
2824
common benchmark setup and run tasks, including replicating the automated
29-
overnight run locally. See `python bm_runner.py --help` for detail.
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)).
3030

3131
A significant portion of benchmark run time is environment management. Run-time
3232
can be reduced by placing the benchmark environment on the same file system as

docs/src/whatsnew/latest.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ This document explains the changes made to Iris for this release
102102
benchmark runs, and introduced larger more 'real world' benchmarks where
103103
coverage was needed. (:pull:`5949`).
104104

105+
#. `@trexfeathers`_ made a Nox `benchmarks` session as the recommended entry
106+
point for running benchmarks. (:pull:`5951`)
107+
105108

106109
.. comment
107110
Whatsnew author names (@github name) in alphabetical order. Note that,

noxfile.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,27 @@ def wheel(session: nox.sessions.Session):
291291
"import iris; print(f'{iris.__version__=}')",
292292
external=True,
293293
)
294+
295+
296+
@nox.session
297+
def benchmarks(session: nox.sessions.Session):
298+
"""Run the Iris benchmark runner. Run session with `-- --help` for help.
299+
300+
Parameters
301+
----------
302+
session : object
303+
A `nox.sessions.Session` object.
304+
305+
"""
306+
if len(session.posargs) == 0:
307+
message = (
308+
"This session MUST be run with at least one argument. The "
309+
"arguments are passed down to the benchmark runner script. E.g:\n"
310+
"nox -s benchmarks -- --help\n"
311+
"nox -s benchmarks -- something --help\n"
312+
"nox -s benchmarks -- something\n"
313+
)
314+
session.error(message)
315+
session.install("asv", "nox")
316+
with session.chdir(Path(__file__).parent / "benchmarks"):
317+
session.run("python", "bm_runner.py", *session.posargs)

0 commit comments

Comments
 (0)