Skip to content

Commit 8fe5ffd

Browse files
committed
Move amici.petab to amici.importers.petab
and all petab v1 functionality to amici.importers.petab.v1.
1 parent 853104c commit 8fe5ffd

Some content is hidden

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

42 files changed

+152
-129
lines changed

.github/workflows/test_petab_sciml.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: Install python package
5757
run: scripts/installAmiciSource.sh
5858

59-
- name: Install petab
59+
- name: Install Python dependencies
6060
run: |
6161
source ./venv/bin/activate \
6262
&& pip3 install wheel pytest shyaml pytest-cov
@@ -65,14 +65,16 @@ jobs:
6565
- name: Download and install PEtab SciML
6666
run: |
6767
source ./venv/bin/activate \
68-
&& python -m pip install git+https://github.com/petab-dev/petab_sciml.git@main#subdirectory=src/python \
69-
68+
&& python -m pip install git+https://github.com/petab-dev/petab_sciml.git@main#subdirectory=src/python
7069
7170
- name: Install petab
71+
# FIXME: Currently, an older version of petab that is required for
72+
# these tests, because petab-sciml is currently a mix of petab v1
73+
# and v2 functionality.
7274
run: |
7375
source ./venv/bin/activate \
7476
&& python3 -m pip uninstall -y petab \
75-
&& python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@sciml \
77+
&& python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@sciml
7678
7779
- name: Run PEtab SciML testsuite
7880
run: |

doc/examples/example_errors.ipynb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
]
1212
},
1313
{
14-
"cell_type": "code",
15-
"execution_count": null,
16-
"id": "1863901917703506",
1714
"metadata": {},
15+
"cell_type": "code",
1816
"outputs": [],
17+
"execution_count": null,
1918
"source": [
2019
"%matplotlib inline\n",
2120
"import os\n",
@@ -34,8 +33,12 @@
3433
" run_simulation,\n",
3534
" simulation_status_to_str,\n",
3635
")\n",
37-
"from amici.petab.petab_import import import_petab_problem\n",
38-
"from amici.petab.simulations import EDATAS, RDATAS, simulate_petab\n",
36+
"from amici.importers.petab.v1 import (\n",
37+
" EDATAS,\n",
38+
" RDATAS,\n",
39+
" import_petab_problem,\n",
40+
" simulate_petab,\n",
41+
")\n",
3942
"from amici.plotting import plot_jacobian, plot_state_trajectories\n",
4043
"from petab.v1.sbml import get_sbml_model\n",
4144
"\n",
@@ -48,7 +51,8 @@
4851
" import benchmark_models_petab\n",
4952
" except ModuleNotFoundError:\n",
5053
" print(\"** Please restart the kernel. **\")"
51-
]
54+
],
55+
"id": "b9e6cb8843da8bc3"
5256
},
5357
{
5458
"cell_type": "markdown",

doc/examples/example_jax/ExampleJax.ipynb

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,23 +274,16 @@
274274
]
275275
},
276276
{
277+
"metadata": {},
277278
"cell_type": "code",
278-
"execution_count": 4,
279-
"id": "6ada3fb8",
280-
"metadata": {
281-
"ExecuteTime": {
282-
"start_time": "2024-10-18T20:36:51.765461Z"
283-
},
284-
"jupyter": {
285-
"is_executing": true
286-
}
287-
},
288279
"outputs": [],
280+
"execution_count": null,
289281
"source": [
290-
"from amici.petab.petab_import import import_petab_problem\n",
282+
"from amici.importers.petab.v1 import import_petab_problem\n",
291283
"\n",
292284
"amici_model = import_petab_problem(petab_problem, compile_=True, verbose=False)"
293-
]
285+
],
286+
"id": "4c510f3e65879888"
294287
},
295288
{
296289
"cell_type": "markdown",
@@ -311,14 +304,13 @@
311304
]
312305
},
313306
{
314-
"cell_type": "code",
315-
"execution_count": 5,
316-
"id": "72053647",
317307
"metadata": {},
308+
"cell_type": "code",
318309
"outputs": [],
310+
"execution_count": null,
319311
"source": [
320312
"import amici\n",
321-
"from amici.petab.simulations import simulate_petab\n",
313+
"from amici.importers.petab.v1 import simulate_petab\n",
322314
"\n",
323315
"amici_solver = amici_model.create_solver()\n",
324316
"amici_solver.set_sensitivity_order(amici.SensitivityOrder.first)\n",
@@ -336,7 +328,8 @@
336328
" tuple(ret[\"sllh\"][par_id] for par_id in petab_problem.x_free_ids)\n",
337329
" )\n",
338330
" return llh, sllh"
339-
]
331+
],
332+
"id": "beb890bd2f3d0880"
340333
},
341334
{
342335
"cell_type": "markdown",

doc/examples/example_jax_petab/ExampleJaxPEtab.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"outputs": [],
3333
"source": [
3434
"import petab.v1 as petab\n",
35-
"from amici.petab.petab_import import import_petab_problem\n",
35+
"from amici.importers.petab.v1 import import_petab_problem\n",
3636
"\n",
3737
"# Define the model name and YAML file location\n",
3838
"model_name = \"Boehm_JProteomeRes2014\"\n",
@@ -566,7 +566,7 @@
566566
"outputs": [],
567567
"source": [
568568
"import amici\n",
569-
"from amici.petab import simulate_petab\n",
569+
"from amici.importers.petab.v1 import simulate_petab\n",
570570
"\n",
571571
"# Import the PEtab problem as a standard AMICI model\n",
572572
"amici_model = import_petab_problem(\n",

doc/examples/example_petab/petab.ipynb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@
1212
]
1313
},
1414
{
15-
"cell_type": "code",
16-
"execution_count": null,
1715
"metadata": {},
16+
"cell_type": "code",
1817
"outputs": [],
18+
"execution_count": null,
1919
"source": [
2020
"import petab\n",
2121
"from amici import run_simulation\n",
22-
"from amici.petab.petab_import import import_petab_problem\n",
23-
"from amici.petab.petab_problem import PetabProblem\n",
24-
"from amici.petab.simulations import simulate_petab\n",
22+
"from amici.importers.petab.v1 import (\n",
23+
" import_petab_problem,\n",
24+
" simulate_petab,\n",
25+
")\n",
26+
"from amici.importers.petab.v1.petab_problem import PetabProblem\n",
2527
"from amici.plotting import plot_state_trajectories"
2628
]
2729
},

doc/examples/example_petab/petab_v2.ipynb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,19 @@
1313
]
1414
},
1515
{
16+
"metadata": {},
1617
"cell_type": "code",
17-
"id": "initial_id",
18-
"metadata": {
19-
"collapsed": true
20-
},
18+
"outputs": [],
19+
"execution_count": null,
2120
"source": [
2221
"import logging\n",
2322
"\n",
2423
"import amici\n",
25-
"from amici.petab.petab_importer import *\n",
26-
"from amici.petab.simulations import RDATAS\n",
24+
"from amici.importers.petab import *\n",
2725
"from amici.plotting import *\n",
2826
"from petab.v2 import Problem"
2927
],
30-
"outputs": [],
31-
"execution_count": null
28+
"id": "419616ae233de558"
3229
},
3330
{
3431
"cell_type": "markdown",

doc/python_modules.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ AMICI Python API
1717
amici.importers.pysb
1818
amici.importers.bngl
1919
amici.importers.antimony
20-
amici.petab
21-
amici.petab.conditions
22-
amici.petab.import_helpers
23-
amici.petab.parameter_mapping
24-
amici.petab.petab_import
25-
amici.petab.petab_importer
26-
amici.petab.pysb_import
27-
amici.petab.sbml_import
28-
amici.petab.simulations
29-
amici.petab.simulator
20+
amici.importers.petab
21+
amici.importers.petab.v1
22+
amici.importers.petab.v1.conditions
23+
amici.importers.petab.v1.import_helpers
24+
amici.importers.petab.v1.parameter_mapping
25+
amici.importers.petab.v1.petab_import
26+
amici.importers.petab.v1.pysb_import
27+
amici.importers.petab.v1.sbml_import
28+
amici.importers.petab.v1.simulations
29+
amici.importers.petab.v1.simulator
3030
amici.jax
3131
amici.exporters.sundials.de_export
3232
amici.de_model

python/sdist/amici/adapters/fiddy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
from petab.v1.C import LIN, LOG, LOG10
1919

2020
import amici
21-
import amici.petab.simulations
22-
from amici.petab.conditions import create_edatas
23-
from amici.petab.parameter_mapping import create_parameter_mapping
24-
from amici.petab.simulations import LLH, SLLH
21+
import amici.importers.petab.v1.simulations
22+
from amici.importers.petab import LLH, SLLH
23+
from amici.importers.petab.v1.conditions import create_edatas
24+
from amici.importers.petab.v1.parameter_mapping import create_parameter_mapping
2525

2626
from .. import ReturnData, SensitivityOrder
2727

2828
if TYPE_CHECKING:
29-
from amici.petab.petab_importer import PetabSimulator
29+
from amici.importers.petab import PetabSimulator
3030

3131
__all__ = [
3232
"run_simulation_to_cached_functions",
@@ -326,7 +326,7 @@ def simulate_petab_to_cached_functions(
326326
free_parameter_ids = list(petab_problem.parameter_df.index)
327327

328328
if simulate_petab is None:
329-
simulate_petab = amici.petab.simulations.simulate_petab
329+
simulate_petab = amici.importers.petab.v1.simulations.simulate_petab
330330

331331
edatas = None
332332
if precreate_edatas:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
PEtab import related code.
3+
4+
This submodule contains all functionality related to importing PEtab problems.
5+
6+
For importing and simulating
7+
`PEtab v2 <https://petab.readthedocs.io/en/latest/v2/documentation_data_format.html#>`__
8+
problems, the relevant classes are:
9+
10+
* :class:`PetabImporter`: Import a PEtab problem as an AMICI model.
11+
* :class:`PetabSimulator`: Simulate PEtab problems with AMICI.
12+
* :class:`ExperimentManager`: Create :class:`amici.ExpData` objects for PEtab
13+
experiments.
14+
15+
See :doc:`/examples/example_petab/petab_v2` for example usage.
16+
Note that the PEtab v2 API is still under development and may change in future
17+
releases.
18+
19+
The PEtab legacy v1 import functionality is still available under
20+
:mod:`amici.importers.petab.v1`.
21+
Note that this functionality will be deprecated once the PEtab v2 import is
22+
stable.
23+
Most PEtab v1 problems can be also imported using the PEtab v2 import by
24+
passing a :class:`petab.v1.Problem` instance to the PEtab v2 import functions.
25+
"""
26+
27+
from ._petab_importer import * # noqa: F403, F401

python/sdist/amici/petab/cli/import_petab.py renamed to python/sdist/amici/importers/petab/_cli/import_petab.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import argparse
22

33
import petab.v1 as petab
4-
5-
from ..petab_import import import_model_sbml
4+
from amici.importers.petab.v1.petab_import import import_model_sbml
65

76

87
def _parse_cli_args():

0 commit comments

Comments
 (0)