Skip to content

Commit 797845b

Browse files
Add python package (#167)
* add python package * add unit test * fix typo * fix dir * restrict to push * address comments from code review * fixi * add test * remove deploy; use full paths * add install.md * why does ci fail * fix intention * fix sth * fixup * Update INSTALL.md
1 parent 72c8500 commit 797845b

18 files changed

Lines changed: 290 additions & 0 deletions

File tree

.github/workflows/python.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Python CI
2+
3+
# trigger
4+
on: [push]
5+
6+
jobs:
7+
base:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: ['3.10']
12+
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v2
16+
17+
- name: Prepare python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Run tests from editable install
23+
run: |
24+
cd src/python
25+
pip install --upgrade pip
26+
pip install -e .
27+
pip install pytest
28+
pytest test
29+
30+
- name: Run tests from sdist install
31+
run: |
32+
cd src/python
33+
./build.sh
34+
pip install pytest
35+
pytest test
36+
37+
lint:
38+
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
python-version: ['3.10']
42+
43+
steps:
44+
- name: Check out repository
45+
uses: actions/checkout@v2
46+
47+
- name: Prepare python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v1
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
52+
- name: Run pre-commit hooks
53+
run: |
54+
pip install pre-commit
55+
pre-commit run --all-files

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
*.DS_store
33
~$*
44
__pycache__
5+
*egg-info
6+
src/python/build

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
files: src/python
2+
repos:
3+
- repo: https://github.com/psf/black
4+
rev: 22.3.0
5+
hooks:
6+
- id: black
7+
description: The uncompromising code formatter
8+
- repo: https://github.com/pycqa/isort
9+
rev: 5.10.1
10+
hooks:
11+
- id: isort
12+
name: isort
13+
- repo: https://github.com/pycqa/flake8
14+
rev: 5.0.4
15+
additional_dependencies: [flake8-docstrings]
16+
hooks:
17+
- id: flake8
18+
args: [--config, src/python/setup.cfg]

INSTALL.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Install
2+
3+
There are various ways of installing or downloading the benchmark models:
4+
5+
## Git clone
6+
7+
The repository containing the benchmark models can be cloned from GitHub via:
8+
9+
git clone git@github.com:Benchmarking-Initiative/Benchmark-Models-PEtab.git
10+
11+
## Download source files
12+
13+
The Benchmark files can be downloaded from GitHub as a
14+
[ZIP file](https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab/archive/refs/heads/master.zip).
15+
16+
## Python package
17+
18+
We provide a Python utility package that simplifies the installation and
19+
provides access functionality at [src/python](src/python).
20+
21+
It can be installed directly from GitHub via:
22+
23+
pip install git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master#subdirectory=src/python
24+
25+
Alternatively, when the whole repository has been cloned (see above),
26+
the python package can be installed via
27+
28+
cd src/python
29+
30+
followed by either an in-place develop mode installation:
31+
32+
pip install -e .
33+
34+
or a packaged installation:
35+
36+
./build.sh
37+
pip install build/dist/*
38+
39+
Note that when the repository models are updated, also the python package needs
40+
to be updated, as it does not actively synchronize.
41+
42+
Once installed, the python package can be used via:
43+
44+
```python
45+
import benchmark_models_petab as models
46+
47+
# print models base folder
48+
print(models.MODELS_DIR)
49+
# print all model names
50+
print(models.MODELS)
51+
# generate petab problem
52+
petab_problem = models.get_problem("Zheng_PNAS2012")
53+
```
54+
55+
For provided functionality, see the
56+
[source code documentation](src/python/benchmark_models_petab).

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ Contributions to the collection are very welcome. For this, please create a new
4343
Any original content in this repository may be used under the terms of the [BSD-3-Clause license](LICENSE).
4444
Different terms may apply to models and datasets, for which we refer the user to the original publications
4545
that are referenced in the respective SBML files.
46+
47+
## Installation
48+
49+
See [INSTALL.md](INSTALL.md).

src/python/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../LICENSE

src/python/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include benchmark_models_petab/Benchmark-Models/*/*

src/python/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Benchmark-Models
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Constants."""
2+
3+
import os
4+
from typing import List
5+
6+
BASE_DIR: str = os.path.abspath(os.path.dirname(__file__))
7+
MODELS_DIR: str = os.path.join(BASE_DIR, "Benchmark-Models")
8+
9+
MODELS: List[str] = os.listdir(MODELS_DIR)
10+
MODEL_DIRS: List[str] = [os.path.join(MODELS_DIR, d) for d in MODELS]

0 commit comments

Comments
 (0)