Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use petab.v1 #2471

Merged
merged 7 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test_benchmark_collection_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ jobs:
AMICI_PARALLEL_COMPILE="" pip3 install -v --user \
$(ls -t python/sdist/dist/amici-*.tar.gz | head -1)[petab,test,vis]

- run: |
python3 -m pip uninstall -y petab && python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@develop \
&& python3 -m pip install -U sympy

# retrieve test models
- name: Download and test benchmark collection
run: |
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/test_petab_test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Install petab
run: |
source ./venv/bin/activate \
&& pip3 install wheel pytest shyaml pytest-cov pysb
&& pip3 install wheel pytest shyaml pytest-cov pysb>=1.16

# retrieve test models
- name: Download and install PEtab test suite
Expand All @@ -68,11 +68,20 @@ jobs:
&& source ./venv/bin/activate \
&& cd petab_test_suite && pip3 install -e .

- name: Install petab
run: |
source ./venv/bin/activate \
&& python3 -m pip uninstall -y petab \
&& python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@develop \
&& python3 -m pip install git+https://github.com/FFroehlich/pysb@fix_pattern_matching \
&& python3 -m pip install sympy>=1.12.1


- name: Run PEtab-related unit tests
run: |
source ./venv/bin/activate \
&& pytest --cov-report=xml:coverage.xml \
--cov=./ python/tests/test_*petab*.py python/tests/petab/
--cov=./ python/tests/test_*petab*.py python/tests/petab_/

# run test models
- name: Run PEtab test suite
Expand Down
4 changes: 3 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
addopts = -vv --strict-markers

filterwarnings =
# warnings are errors
error
# petab
ignore:Using petab.v1.Problem with PEtab2.0 is deprecated:DeprecationWarning
# amici
ignore:Conservation laws for non-constant species in models with RateRules are currently not supported and will be turned off.:UserWarning
ignore:Conservation laws for non-constant species in models with Species-AssignmentRules are currently not supported and will be turned off.:UserWarning
Expand All @@ -13,7 +16,6 @@ filterwarnings =
ignore:.*inspect.getargspec\(\) is deprecated.*:DeprecationWarning
# pysb warnings
ignore:the imp module is deprecated in favour of importlib.*:DeprecationWarning:pysb\.core
ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working.*:DeprecationWarning:pysb\.core
ignore:Model.initial_conditions will be removed in a future version. Instead, you can get a list of Initial objects with Model.initials.:DeprecationWarning:pysb\.core
# https://github.com/pytest-dev/pytest-xdist/issues/825#issuecomment-1292283870
ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning
Expand Down
2 changes: 1 addition & 1 deletion python/sdist/amici/petab/cli/import_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import petab

from ..petab_import import import_model_sbml
from petab.models.sbml_model import SbmlModel
from petab.v1.models.sbml_model import SbmlModel


def _parse_cli_args():
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/petab/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import amici
import numpy as np
import pandas as pd
import petab
import petab.v1 as petab
from amici import AmiciModel
from petab.C import (
from petab.v1.C import (
MEASUREMENT,
NOISE_PARAMETERS,
OBSERVABLE_ID,
Expand Down
6 changes: 3 additions & 3 deletions python/sdist/amici/petab/import_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

import amici
import pandas as pd
import petab
import petab.v1 as petab
import sympy as sp
from petab.C import (
from petab.v1.C import (
CONDITION_NAME,
ESTIMATE,
NOISE_DISTRIBUTION,
Expand All @@ -22,7 +22,7 @@
OBSERVABLE_NAME,
OBSERVABLE_TRANSFORMATION,
)
from petab.parameters import get_valid_parameters_for_parameter_table
from petab.v1.parameters import get_valid_parameters_for_parameter_table
from sympy.abc import _clash

logger = logging.getLogger(__name__)
Expand Down
8 changes: 4 additions & 4 deletions python/sdist/amici/petab/parameter_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
import amici
import numpy as np
import pandas as pd
import petab
import petab.v1 as petab
import sympy as sp
from amici.sbml_import import get_species_initial
from petab.C import * # noqa: F403
from petab.C import (
from petab.v1.C import * # noqa: F403
from petab.v1.C import (
LIN,
PARAMETER_SCALE,
PREEQUILIBRATION_CONDITION_ID,
SIMULATION_CONDITION_ID,
)
from petab.models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML
from petab.v1.models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML
from sympy.abc import _clash

from .. import AmiciModel
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/petab/petab_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from warnings import warn

import amici
import petab
from petab.models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML
import petab.v1 as petab
from petab.v1.models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML

from ..logging import get_logger
from .import_helpers import _can_import_model, _create_model_name, check_model
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/petab/petab_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import amici
import pandas as pd
import petab
from petab.C import PREEQUILIBRATION_CONDITION_ID, SIMULATION_CONDITION_ID
import petab.v1 as petab
from petab.v1.C import PREEQUILIBRATION_CONDITION_ID, SIMULATION_CONDITION_ID

from .conditions import create_edatas, fill_in_parameters
from .parameter_mapping import create_parameter_mapping
Expand Down
6 changes: 3 additions & 3 deletions python/sdist/amici/petab/pysb_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import re
from pathlib import Path

import petab
import petab.v1 as petab
import pysb
import pysb.bng
import sympy as sp
from petab.C import CONDITION_NAME, NOISE_FORMULA, OBSERVABLE_FORMULA
from petab.models.pysb_model import PySBModel
from petab.v1.C import CONDITION_NAME, NOISE_FORMULA, OBSERVABLE_FORMULA
from petab.v1.models.pysb_model import PySBModel

from ..logging import get_logger, log_execution_time, set_log_level
from . import PREEQ_INDICATOR_ID
Expand Down
6 changes: 3 additions & 3 deletions python/sdist/amici/petab/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import amici
import libsbml
import petab
import petab.v1 as petab
import sympy as sp
from _collections import OrderedDict
from amici.logging import log_execution_time, set_log_level
from petab.models import MODEL_TYPE_SBML
from petab.v1.models import MODEL_TYPE_SBML
from sympy.abc import _clash

from . import PREEQ_INDICATOR_ID
Expand Down Expand Up @@ -90,7 +90,7 @@ def import_model_sbml(
:return:
The created :class:`amici.sbml_import.SbmlImporter` instance.
"""
from petab.models.sbml_model import SbmlModel
from petab.v1.models.sbml_model import SbmlModel

set_log_level(logger, verbose)

Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/petab/simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import amici
import numpy as np
import pandas as pd
import petab
from petab.C import * # noqa: F403
import petab.v1 as petab
from petab.v1.C import * # noqa: F403

from .. import AmiciExpData, AmiciModel
from ..logging import get_logger, log_execution_time
Expand Down
2 changes: 1 addition & 1 deletion python/sdist/amici/petab/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from collections.abc import Callable

import pandas as pd
import petab
import petab.v1 as petab
from amici import AmiciModel, SensitivityMethod_none

from .petab_import import import_petab_problem
Expand Down
8 changes: 4 additions & 4 deletions python/sdist/amici/petab/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import libsbml
import pandas as pd
import petab
from petab.C import PREEQUILIBRATION_CONDITION_ID, SIMULATION_CONDITION_ID
from petab.mapping import resolve_mapping
from petab.models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML
import petab.v1 as petab
from petab.v1.C import PREEQUILIBRATION_CONDITION_ID, SIMULATION_CONDITION_ID
from petab.v1.mapping import resolve_mapping
from petab.v1.models import MODEL_TYPE_PYSB, MODEL_TYPE_SBML

if TYPE_CHECKING:
pysb = None
Expand Down
2 changes: 1 addition & 1 deletion python/sdist/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ classifiers = [
# Don't include any URLs here - they are not supported by PyPI:
# HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
# Invalid value for requires_dist. Error: Can't have direct dependency: ...
petab = ["petab>=0.2.9"]
petab = ["petab>=0.4.0"]
pysb = ["pysb>=1.13.1"]
test = [
"benchmark_models_petab @ git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master#subdirectory=src/python",
Expand Down
4 changes: 2 additions & 2 deletions python/tests/splines_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import amici
import numpy as np
import pandas as pd
import petab
import petab.v1 as petab
import sympy as sp
from amici.gradient_check import _check_results
from amici.petab.petab_import import import_petab_problem
Expand All @@ -31,7 +31,7 @@
)
from amici.splines import AbstractSpline, CubicHermiteSpline, UniformGrid
from amici.testing import TemporaryDirectoryWinSafe as TemporaryDirectory
from petab.models.sbml_model import SbmlModel
from petab.v1.models.sbml_model import SbmlModel


def evaluate_spline(
Expand Down
6 changes: 3 additions & 3 deletions python/tests/test_petab_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from amici.testing import TemporaryDirectoryWinSafe, skip_on_valgrind

petab = pytest.importorskip("petab", reason="Missing petab")
petab = pytest.importorskip("petab.v1", reason="Missing petab")


@pytest.fixture
Expand Down Expand Up @@ -76,7 +76,7 @@ def test_get_fixed_parameters(get_fixed_parameters_model):
from amici.petab.sbml_import import (
_get_fixed_parameters_sbml as get_fixed_parameters,
)
from petab.models.sbml_model import SbmlModel
from petab.v1.models.sbml_model import SbmlModel

sbml_doc, sbml_model = get_fixed_parameters_model
condition_df = petab.get_condition_df(
Expand Down Expand Up @@ -117,7 +117,7 @@ def test_get_fixed_parameters(get_fixed_parameters_model):
@skip_on_valgrind
def test_default_output_parameters(simple_sbml_model):
from amici.petab.petab_import import import_model
from petab.models.sbml_model import SbmlModel
from petab.v1.models.sbml_model import SbmlModel

sbml_doc, sbml_model = simple_sbml_model
condition_df = petab.get_condition_df(
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_petab_objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import amici
import numpy as np
import pandas as pd
import petab
import petab.v1 as petab
import pytest
from amici.petab.petab_import import import_petab_problem
from amici.petab.simulations import SLLH, simulate_petab
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_petab_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tempfile
from pathlib import Path

import petab
import petab.v1 as petab
import petabtests
import pytest
from amici.petab.simulator import PetabSimulator
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmark-models/test_petab_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import amici
import numpy as np
import pandas as pd
import petab
import petab.v1 as petab
import pytest
from amici.petab.petab_import import import_petab_problem

Expand Down
4 changes: 2 additions & 2 deletions tests/benchmark-models/test_petab_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import amici
import numpy as np
import pandas as pd
import petab
import petab.v1 as petab
import yaml
from amici.logging import get_logger
from amici.petab.simulations import (
Expand All @@ -24,7 +24,7 @@
rdatas_to_measurement_df,
simulate_petab,
)
from petab.visualize import plot_problem
from petab.v1.visualize import plot_problem

logger = get_logger(f"amici.{__name__}", logging.WARNING)

Expand Down
2 changes: 1 addition & 1 deletion tests/petab_test_suite/test_petab_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import amici
import pandas as pd
import petab
import petab.v1 as petab
import petabtests
import pytest
from _pytest.outcomes import Skipped
Expand Down
Loading