Skip to content

Commit 29aff05

Browse files
dilpathDilan Pathiranadweindl
authored
Release v0.2.0
* make model hashes nicer; add model hash to model method * :class:`ModelHash` * support user-supplied models with no specified subspace * Skip virtual models in `models_to_yaml_list` (#66) * Action updates via dependabot (#92) * GHA: Add PyPI deployment workflow (#91) Related to #89 * Fix minimum Python requirement (#97) petab requires python>=3.10 * Doc: Fix heading levels in example (#96) Fixes the sphinx TOC and a typo. * Get rid of petab DeprecationWarnings (#93) Closes #90 * README.md: PyPI badge * Add some docs; ensure similar PEtab problems in distance calculation (#67) * File formats to RTD (#102) * Move test suite description to RTD (#101) Related to #95. * User-calibrated models (#87) * compute safe petab hash digest size; support custom digest size; refactor `CandidateSpace` excluded hashes; add `end_iteration`; rename `candidates`->`start_iteration`; change workflow as described in changelog * `ModelHash.__eq__`: support comparisons with `str` and partial hashes * repro: narrow bounds in test cases 1-8 * Add logo draft (#103) * add to RTD, closes #88 * Set up `setuptools_scm` (#100) Set up `setuptools_scm` and move most package configuration to `pyproject.toml`. Move git-based package URLs out of `pyproject.toml` (otherwise, PyPI upload will fail). Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com> * Doc: Update RTD landing page (#105) * Doc: Update RTD landing page Add a bit of content. #95. * Apply suggestions from code review Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com> * Formatting, spelling, links --------- Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com> * Switch from black/isort/... to ruff (#99) Replace black/isort/... by ruff. Run `pre-commit run --all-files`. Some additional rules should be enabled, but that will require additional effort. --------- Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com> * Update file format spec (#106) * add example to model space, to clarify compressed format Co-authored-by: Daniel Weindl <dweindl@users.noreply.github.com> * Doc: fix list formatting (#107) * test case 0009: update predecessor model * Visualization methods (#36) * closes #104 --------- Co-authored-by: Daniel Weindl <daniel.weindl@uni-bonn.de> Co-authored-by: Daniel Weindl <dweindl@users.noreply.github.com> * Support SSR as criterion (#108) * closes #44 * changelog --------- Co-authored-by: Dilan Pathirana <dpathira_hpc@login01.service> Co-authored-by: Daniel Weindl <dweindl@users.noreply.github.com> Co-authored-by: Daniel Weindl <daniel.weindl@uni-bonn.de>
2 parents 8d97c58 + 819b4da commit 29aff05

78 files changed

Lines changed: 5674 additions & 2372 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
ignore:
9+
- dependency-name: "*"
10+
update-types: ["version-update:semver-patch", "version-update:semver-minor"]
11+
target-branch: "develop"

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
# test on latest and minimum python version
21-
python-version: ['3.11', '3.9']
21+
python-version: ['3.13', '3.11']
2222

2323
steps:
2424
- name: Check out repository
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy
2+
on:
3+
release:
4+
types:
5+
- published
6+
7+
jobs:
8+
pypi:
9+
name: Deploy PyPI
10+
runs-on: ubuntu-latest
11+
environment:
12+
name: pypi
13+
url: https://pypi.org/p/petab-select
14+
permissions:
15+
id-token: write
16+
17+
steps:
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 20
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install setuptools wheel build
31+
python -m build -s
32+
33+
- name: Publish a Python distribution to PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1

.pre-commit-config.yaml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,8 @@
44
# `pre-commit run --all-files` as by default only changed files are checked
55

66
repos:
7-
- repo: https://github.com/psf/black
8-
rev: 23.10.0
9-
hooks:
10-
- id: black
11-
description: The uncompromising code formatter
12-
- repo: https://github.com/pycqa/isort
13-
rev: 5.12.0
14-
hooks:
15-
- id: isort
16-
name: isort (python)
17-
- id: isort
18-
name: isort (cython)
19-
types: [cython]
20-
- id: isort
21-
name: isort (pyi)
22-
types: [pyi]
23-
- repo: https://github.com/nbQA-dev/nbQA
24-
rev: 1.7.0
25-
hooks:
26-
- id: nbqa-black
27-
- id: nbqa-pyupgrade
28-
args: [--py36-plus]
29-
- id: nbqa-isort
307
- repo: https://github.com/pre-commit/pre-commit-hooks
31-
rev: v4.5.0
8+
rev: v5.0.0
329
hooks:
3310
- id: check-yaml
3411
description: Check yaml files for parseable syntax
@@ -44,3 +21,19 @@ repos:
4421
description: Fix empty lines at ends of files
4522
- id: detect-private-key
4623
description: Detects the presence of private keys
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
# Ruff version.
26+
rev: v0.6.9
27+
hooks:
28+
# Run the linter.
29+
- id: ruff
30+
args:
31+
- --fix
32+
- --config
33+
- pyproject.toml
34+
35+
# Run the formatter.
36+
- id: ruff-format
37+
args:
38+
- --config
39+
- pyproject.toml

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version: 2
99
sphinx:
1010
builder: html
1111
configuration: doc/conf.py
12-
fail_on_warning: True
12+
fail_on_warning: False
1313

1414
python:
1515
install:

README.md

Lines changed: 3 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# PEtab Select
1+
<img src="https://raw.githubusercontent.com/PEtab-dev/petab_select/logo/doc/logo/logo-wide.svg" height="200" alt="PEtab Select logo">
2+
3+
[![PyPI - Version](https://img.shields.io/pypi/v/petab-select)](https://pypi.org/project/petab-select/)
24

35
The repository for the development of the extension to PEtab for model
46
selection, including the additional file formats and Python 3 package.
@@ -44,154 +46,3 @@ given the forward method and a predecessor model with 2 estimated parameters,
4446
if there are no models with 3 estimated parameters, but some models with 4
4547
estimated parameters, then the search may return candidate models with 4
4648
estimated parameters.
47-
48-
## File formats
49-
50-
Column or key names that are surrounding by square brackets
51-
(e.g. `[constraint_files]`) are optional.
52-
53-
### Selection problem
54-
55-
A YAML file with a description of the model selection problem.
56-
57-
```yaml
58-
format_version: [string]
59-
criterion: [string]
60-
method: [string]
61-
model_space_files: [List of filenames]
62-
[constraint_files]: [List of filenames]
63-
[predecessor_model_files]: [List of filenames]
64-
```
65-
66-
- `format_version`: The version of the model selection extension format (
67-
e.g. `'beta_1'`)
68-
- `criterion`: The criterion by which models should be compared (e.g. `'AIC'`)
69-
- `method`: The method by which model candidates should be generated
70-
(e.g. `'forward'`)
71-
- `model_space_files`: The filenames of model space files.
72-
- `constraint_files`: The filenames of constraint files.
73-
- `predecessor_model_files`: The filenames of predecessor (initial) model
74-
files.
75-
76-
### Model space
77-
78-
A TSV with candidate models, in compressed or uncompressed format.
79-
80-
| `model_subspace_id` | `petab_yaml` | [`sbml`] | `parameter_id_1` | ... | `parameter_id_n` |
81-
|---------------------|--------------|----------|------------------------------------------------------|-----|------------------------------------------------------|
82-
| (Unique) [string] | [string] | [string] | [string/float] OR [; delimited list of string/float] | ... | [string/float] OR [; delimited list of string/float] |
83-
84-
- `model_subspace_id`: An ID for the model subspace.
85-
- `petab_yaml`: The PEtab YAML filename that serves as the base for a model.
86-
- `sbml`: An SBML filename. If the PEtab YAML file specifies multiple SBML
87-
models, this can select a specific model by model filename.
88-
- `parameter_id_1`...`parameter_id_n` : Parameter IDs that are specified to
89-
take specific values or be estimated. Example valid values are:
90-
- uncompressed format:
91-
- `0.0`
92-
- `1.0`
93-
- `estimate`
94-
- compressed format
95-
- `0.0;1.1;estimate` (the parameter can take the values `0.0` or `1.1`,
96-
or be estimated according to the PEtab problem)
97-
98-
### Constraints
99-
100-
A TSV file with constraints.
101-
102-
| `petab_yaml` | [`if`] | `constraint` |
103-
|--------------|------------------------------|------------------------------|
104-
| [string] | [SBML L3 Formula expression] | [SBML L3 Formula expression] |
105-
106-
- `petab_yaml`: The filename of the PEtab YAML file that this constraint
107-
applies to.
108-
- `if`: As a single YAML can relate to multiple models in the model space file,
109-
this ensures the constraint is only applied to the models that match
110-
this `if` statement
111-
- `constraint`: If a model violates this constraint, it is skipped during the
112-
model selection process and not optimized.
113-
114-
### Model(s) (Predecessor models / model interchange / report)
115-
116-
- *Predecessor models* are used to initialize an appropriate model selection
117-
method. Model IDs should be unique here and compared to model IDs in any
118-
model space files.
119-
- *Model interchange* refers to the format used to transfer model information
120-
between PEtab Select and a PEtab-compatible calibration tool, during the
121-
model selection process.
122-
- *Report* refers to the final results of the model selection process, which may
123-
include calibration results from any calibrated models, or just the select
124-
model.
125-
126-
Here, the format for a single model is shown. Multiple models can be specified
127-
as a YAML list of the same format.
128-
129-
The only required key is the PEtab YAML, as a model requires a PEtab problem.
130-
All other keys are maybe required, for the different uses of the format (e.g.,
131-
the report format should include `estimated_parameters`), or at different
132-
stages of the model selection process (the PEtab-compatible calibration tool
133-
should provide `criteria` for model comparison).
134-
135-
```yaml
136-
[criteria]: [Dictionary of criterion names and values]
137-
[estimated_parameters]: [Dictionary of parameter IDs and values]
138-
[model_hash]: [string]
139-
[model_id]: [string]
140-
[parameters]: [Dictionary of parameter IDs and values]
141-
petab_yaml: [string]
142-
[predecessor_model_hash]: [string]
143-
[sbml]: [string]
144-
```
145-
146-
- `criteria`: The value of the criterion by which model selection was
147-
performed, at least. Optionally, other criterion values too.
148-
- `estimated_parameters`: Parameter estimates, not only of parameters specified
149-
to be estimated in a model space file, but also parameters specified to be
150-
estimated in the original PEtab problem of the model.
151-
- `model_hash`: The model hash, generated by the PEtab Select library.
152-
- `model_id`: The model ID.
153-
- `model_subspace_id`: Same as in the model space files.
154-
- `model_subspace_indices`: The indices that locate this model in its model
155-
subspace.
156-
- `parameters`: The parameters from the problem (either values
157-
or `'estimate'`) (a specific combination from a model space file, but
158-
uncalibrated).
159-
- `petab_yaml`: Same as in model space files.
160-
- `predecessor_model_hash`: The hash of the model that preceded this model
161-
during the model selection process.
162-
- `sbml`: Same as in model space files.
163-
164-
## Test cases
165-
166-
Several test cases are provided, to test the compatibility of a
167-
PEtab-compatible calibration tool with different PEtab Select features.
168-
169-
The test cases are available in the `test_cases` directory, and are provided in
170-
the model format.
171-
172-
| Test ID | Criterion | Method | Model space files | Compressed format | Constraints files | Predecessor (initial) models files |
173-
|----------------------------------------------|-----------|------------------|-------------------|-------------------|-------------------|------------------------------------|
174-
| 0001 | (all) | (only one model) | 1 | | | |
175-
| 0002<sup>[1](#test_case_0002)</sup> | AIC | forward | 1 | | | |
176-
| 0003 | BIC | all | 1 | Yes | | |
177-
| 0004 | AICc | backward | 1 | | 1 | |
178-
| 0005 | AIC | forward | 1 | | | 1 |
179-
| 0006 | AIC | forward | 1 | | | |
180-
| 0007<sup>[2](#test_case_0007_and_0008)</sup> | AIC | forward | 1 | | | |
181-
| 0008<sup>[2](#test_case_0007_and_0008)</sup> | AICc | backward | 1 | | | |
182-
| 0009<sup>[3](#test_case_0009)</sup> | AICc | FAMoS | 1 | Yes | | Yes |
183-
184-
<a name="test_case_0002">1</a>. Model `M1_0` differs from `M1_1` in three
185-
parameters, but only 1 additional estimated parameter. The effect of this on
186-
model selection criteria needs to be clarified. Test case 0006 is a duplicate
187-
of 0002 that doesn't have this issue.
188-
189-
<a name="test_case_0007_and_0008">2</a>. Noise parameter is removed, noise is
190-
fixed to `1`.
191-
192-
<a name="test_case_0009">3</a>. This is a computationally expensive problem to
193-
solve. Developers can try a model selection initialized with the provided
194-
predecessor model, which is a model start that reproducibly finds the expected
195-
model. To solve the problem reproducibly <i>ab initio</i>, on the order of 100
196-
random model starts are required. This test case reproduces the model selection
197-
problem presented in https://doi.org/10.1016/j.cels.2016.01.002 .

changes.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
11
# Changes
22

3+
## 0.2.0
4+
There are some **major breaking changes**, to support users providing previous calibration results, e.g. from previous model selection runs. The following changes are reflected in the notebook examples.
5+
- **breaking change** previously, calibration tools would call `candidates` at each iteration of model selection. `candidates` has now been renamed to `start_iteration`, and tools are now expected to run `end_iteration` after calibrating the iteration's models. This structure also simplifies the codebase for other features of PEtab Select.
6+
- **breaking change** previously, calibration tools would determine whether to continue model selection based on whether the candidate space contains any models. Now, calibration tools should rely on the `TERMINATE` signal provided by `end_iteration` to determine whether to continue model selection.
7+
- **breaking change** PEtab Select hides user-calibrated models from the calibration tool, until `end_iteration` is called. Hence, if a calibration tool does some analysis on the calibrated models of the current iteration, the tool should use the `MODELS` provided by `end_iteration`, and not the `MODELS` provided by `start_iteration`.
8+
In summary, here's some pseudocode showing the old way.
9+
```python
10+
from petab_select.ui import candidates
11+
while True:
12+
# Get iteration models
13+
models = candidates(...).models
14+
# Terminate if no models
15+
if not models:
16+
break
17+
# Calibrate iteration models
18+
for model in models:
19+
calibrate(model)
20+
# Print a summary/analysis of current iteration models (dummy code)
21+
print_summary_of_iteration_models(models)
22+
```
23+
And here's the new way. Full working examples are given in the updated notebooks, including how to handle the candidate space.
24+
```python
25+
from petab_select.ui import start_iteration, end_iteration
26+
from petab_select.constants import MODELS, TERMINATE
27+
while True:
28+
# Initialize iteration, get uncalibrated iteration models
29+
iteration = start_iteration(...)
30+
# Calibrate iteration models
31+
for model in iteration[MODELS]:
32+
calibrate(model)
33+
# Finalize iteration, get all iteration models and results
34+
iteration_results = end_iteration(...)
35+
# Print a summary/analysis of all iteration models (dummy code)
36+
print_summary_of_iteration_models(iteration_results[MODELS])
37+
# Terminate if indicated
38+
if iteration_results[TERMINATE]:
39+
break
40+
```
41+
- Other **major changes**
42+
- Many thanks to @dweindl for:
43+
- documentation! https://petab-select.readthedocs.io/
44+
- GitHub CI fixes and GHA deployments to PyPI and Zenodo
45+
- fixed a bug introduced in 0.1.8, where FAMoS "jump to most distant" moves were not handled correctly
46+
- the renamed `candidates`->`start_iteration`:
47+
- no longer accepts `calibrated_models`, as they are automatically stored in the `CandidateSpace` now with each `end_iteration`
48+
- `calibrated_models` and `newly_calibrated_models` no longer need to be tracked between iterations. They are now tracked by the candidate space.
49+
- exclusions via `exclude_models` is no longer supported. exclusions can be supplied with `set_excluded_hashes`
50+
- model hashes are more readable and composed of two parts:
51+
1. the model subspace ID
52+
2. the location of the model in its subspace (the model subspace indices)
53+
- users can now provide model calibrations from previous model selection runs. This enables them to skip re-calibration of the same models.
54+
355
## 0.1.13
456
- fixed bug when no predecessor model is provided, introduced in 0.1.11 (#83)
557

doc/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ petab-select Python API
1616
petab_select.model_space
1717
petab_select.model_subspace
1818
petab_select.petab
19+
petab_select.plot
1920
petab_select.problem
2021
petab_select.ui

0 commit comments

Comments
 (0)