Skip to content

Commit 71da562

Browse files
authored
Enable running benchmark/sbml tests from repo root (#2807)
* Allow running benchmark tests from repo root * rename benchmark models * Update run-SBMLTestsuite.sh * more path cleanup * Update evaluate_benchmark.py
1 parent 915cc0a commit 71da562

File tree

14 files changed

+280
-287
lines changed

14 files changed

+280
-287
lines changed

.github/workflows/test_benchmark_collection_models.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
env:
6767
AMICI_PARALLEL_COMPILE: ""
6868
run: |
69-
cd tests/benchmark-models && pytest test_petab_benchmark.py \
69+
pytest tests/benchmark_models/test_petab_benchmark.py \
7070
--durations=10 \
7171
--cov=amici \
7272
--cov-report=xml:"coverage_py.xml" \
@@ -85,14 +85,14 @@ jobs:
8585
# collect & upload results
8686
- name: Aggregate results
8787
run: |
88-
cd tests/benchmark-models && python3 evaluate_benchmark.py
88+
python3 tests/benchmark_models/evaluate_benchmark.py
8989
9090
- uses: actions/upload-artifact@v4
9191
with:
9292
name: computation-times-${{ matrix.python-version }}-${{ matrix.extract_subexpressions }}
9393
path: |
94-
tests/benchmark-models/computation_times.csv
95-
tests/benchmark-models/computation_times.png
94+
tests/benchmark_models/computation_times.csv
95+
tests/benchmark_models/computation_times.png
9696
9797
jax:
9898
name: Benchmark Collection JAX
@@ -142,7 +142,7 @@ jobs:
142142
env:
143143
AMICI_PARALLEL_COMPILE: ""
144144
run: |
145-
cd tests/benchmark-models && pytest test_petab_benchmark_jax.py \
145+
pytest tests/benchmark_models/test_petab_benchmark_jax.py \
146146
--durations=10 \
147147
--cov=amici \
148148
--cov-report=xml:"coverage_py.xml" \

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ tests/sbml/sbml-test-suite/*
137137
tests/sbml/sbml-test-suite/
138138
*/sbml-semantic-test-cases/*
139139
tests/sbml/SBMLTestModels/
140-
tests/benchmark-models/test_bmc
140+
tests/benchmark_models/test_bmc
141141
tests/petab_test_suite
142142
petab_test_suite
143143
*/tests/BIOMD0000000529/*
@@ -193,6 +193,6 @@ Benchmark-Models-PEtab/
193193
CS_Signalling_ERBB_RAS_AKT/
194194
cache_fiddy/*
195195
debug/*
196-
tests/benchmark-models/cache_fiddy/*
196+
tests/benchmark_models/cache_fiddy/*
197197
venv/*
198198
.coverage

doc/AGENTS.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,15 @@ source ./venv/bin/activate
4848

4949
This project uses `pre-commit` for linting and `pytest` for tests. Run them on changed files whenever you make modifications.
5050

51-
When running the tests locally, change into the test directory first:
51+
When running the tests locally, invoke `pytest` from the repository root:
5252

5353
```bash
54-
cd tests/benchmark-models
55-
pytest test_petab_benchmark.py
56-
pytest test_petab_benchmark_jax.py
54+
pytest tests/benchmark_models/test_petab_benchmark.py
55+
pytest tests/benchmark_models/test_petab_benchmark_jax.py
5756
```
5857

5958
To quickly verify the benchmark tests, you can limit execution to a small model:
6059

6160
```bash
62-
pytest -k Boehm_JProteomeRes2014 test_petab_benchmark.py
61+
pytest tests/benchmark_models/test_petab_benchmark.py -k Boehm_JProteomeRes2014
6362
```

scripts/run-SBMLTestsuite.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ if [[ ! -d "tests/sbml/sbml-test-suite" ]]; then
1010
fi
1111

1212
source venv/bin/activate
13-
export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}."
1413
pip show pytest-xdist > /dev/null 2>&1 || pip install pytest-xdist
1514
pip install coverage pytest-cov
1615

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ This directory contains:
77
interface (`sbml/`)
88
- Scripts for running the PEtab test suite, exercising the Python interface (`petab_test_suite/`)
99
- Scripts for testing AMICI performance for importing a somewhat larger model (`performance/`)
10-
- Scripts for running the PEtab benchmark suite, exercising the Python interface (`benchmark-models/`)
10+
- Scripts for running the PEtab benchmark suite, exercising the Python interface (`benchmark_models/`)

tests/benchmark-models/conftest.py renamed to tests/benchmark_models/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import copy
22
from pathlib import Path
3+
import sys
34

45
import pytest
56
import petab.v1 as petab
@@ -8,9 +9,12 @@
89
import benchmark_models_petab
910
from amici.petab.petab_import import import_petab_problem
1011

12+
script_dir = Path(__file__).parent.resolve()
13+
if str(script_dir) not in sys.path:
14+
sys.path.insert(0, str(script_dir))
15+
1116
from test_petab_benchmark import problems
1217

13-
script_dir = Path(__file__).parent
1418
repo_root = script_dir.parent.parent
1519
benchmark_outdir = repo_root / "test_bmc"
1620

tests/benchmark-models/evaluate_benchmark.py renamed to tests/benchmark_models/evaluate_benchmark.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
import matplotlib.pyplot as plt
1010
import pandas as pd
1111
import seaborn as sns
12+
from pathlib import Path
1213

1314
# read benchmark results for different models
1415

16+
benchmark_dir = Path(__file__).parent.resolve()
17+
1518
outfile = "computation_times.csv"
1619
df = pd.concat(
1720
[
18-
pd.read_csv(f, header=[0], index_col=[0])
21+
pd.read_csv(benchmark_dir / f, header=[0], index_col=[0])
1922
.rename(columns={"0": "_".join(f.split("_")[:2])})
2023
.T
21-
for f in os.listdir()
24+
for f in os.listdir(benchmark_dir)
2225
if f.endswith(".csv")
2326
if f != outfile
2427
]

tests/benchmark-models/test_petab_benchmark_jax.py renamed to tests/benchmark_models/test_petab_benchmark_jax.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
from amici.jax.petab import run_simulations, JAXProblem
1313
from amici.petab.petab_import import import_petab_problem
1414
from amici.petab.simulations import simulate_petab, LLH, SLLH
15-
import test_petab_benchmark as common
16-
17-
settings = common.settings
18-
problems_for_gradient_check = common.problems_for_gradient_check
19-
benchmark_outdir = common.benchmark_outdir
15+
from test_petab_benchmark import (
16+
benchmark_outdir,
17+
problems_for_gradient_check,
18+
settings,
19+
)
2020

2121
jax.config.update("jax_enable_x64", True)
2222

0 commit comments

Comments
 (0)