Skip to content

Commit e5a7091

Browse files
authored
Merge pull request #59 from Langhaarzombie/feature/buildkite-python
Add miniconda setup and python specific configurations, and update the qutip benchmark collection paths.
2 parents c73de9f + af31444 commit e5a7091

File tree

3 files changed

+46
-9
lines changed

3 files changed

+46
-9
lines changed

.buildkite/benchmark.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ steps:
2222

2323
- label: "Run QuTiP benchmarks"
2424
command: |
25-
apt-get update -y
26-
apt-get install -y python3-pip
25+
mkdir -p ~/miniconda3
26+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
27+
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
28+
source ~/miniconda3/bin/activate
29+
conda init --all
30+
31+
conda create -y -n qutip-benchmark python
32+
conda activate qutip-benchmark
2733
2834
python3 --version
2935
pip3 --version
@@ -32,7 +38,7 @@ steps:
3238
3339
python3 -m benchmark.qutip.runbenchmark -v -s
3440
artifact_paths:
35-
- "benchmark/results/*"
41+
- "benchmark/results/qutip/*"
3642
agents:
3743
queue: "juliagpu"
3844
cuda: "*"

benchmark/qutip/runbenchmark.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
import sys
2+
import argparse
23
import pytest
34

4-
def run_benchmarks():
5+
def run_benchmarks(args):
6+
"""Run pytest benchmarks with defaults and optional additional args."""
7+
58
return pytest.main(
69
[
710
"benchmark/qutip/scripts",
811
"--benchmark-only",
912
"--benchmark-columns=Mean,StdDev,rounds,Iterations",
1013
"--benchmark-sort=name",
1114
"--benchmark-autosave",
12-
"--benchmark-storage=./benchmark/results/"
15+
"--benchmark-storage=./benchmark/results/qutip/",
16+
"--durations=0",
17+
"--durations-min=1.0",
18+
"-Wdefault",
1319
]
20+
+ args
1421
)
1522

16-
1723
def main():
18-
exit_code = run_benchmarks()
19-
return exit_code
20-
24+
pars = argparse.ArgumentParser(
25+
description="""
26+
Run the benchmarks for QuTiP. The script also accepts the same
27+
arguments as pytest/pytest-benchmark. Run the script from the
28+
root directory of the repository.
29+
"""
30+
)
31+
_, other_args = pars.parse_known_args()
32+
return run_benchmarks(other_args)
2133

2234
if __name__ == "__main__":
2335
sys.exit(main())
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from importlib.metadata import version, PackageNotFoundError
2+
3+
def pkg_version(package):
4+
try:
5+
return version(package)
6+
except PackageNotFoundError:
7+
return None
8+
9+
def pytest_benchmark_update_json(config, benchmarks, output_json):
10+
"""Adds the version of selected packages to the benchmarks' output JSON."""
11+
12+
output_json["package_versions"] = {}
13+
output_json["package_versions"]["scipy"] = pkg_version("scipy")
14+
output_json["package_versions"]["numpy"] = pkg_version("numpy")
15+
output_json["package_versions"]["cython"] = pkg_version("cython")
16+
output_json["package_versions"]["qutip"] = pkg_version("qutip")
17+
output_json["package_versions"]["qutip-jax"] = pkg_version("qutip-jax")
18+
output_json["package_versions"]["jax"] = pkg_version("jax")
19+
output_json["package_versions"]["pytest"] = pkg_version("pytest")

0 commit comments

Comments
 (0)