Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@
"Example:\n",
"```bash\n",
"petab_yaml=\"https://raw.githubusercontent.com/Benchmarking-Initiative/Benchmark-Models-PEtab/master/Benchmark-Models/Froehlich_CellSystems2018/Froehlich_CellSystems2018.yaml\"\n",
"/usr/bin/time -v amici_import_petab -y \"$petab_yaml\" --no-compile\n",
"/usr/bin/time -v amici_import_petab \"$petab_yaml\" --no-compile\n",
"# vs.\n",
"/usr/bin/time -v amici_import_petab -y \"$petab_yaml\" --no-compile --no-sensitivities\n",
"/usr/bin/time -v amici_import_petab \"$petab_yaml\" --no-compile --no-sensitivities\n",
"```"
]
},
Expand Down
94 changes: 3 additions & 91 deletions python/sdist/amici/petab/cli/import_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import petab.v1 as petab

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


def _parse_cli_args():
Expand Down Expand Up @@ -59,48 +58,6 @@
help="Skip generation of sensitivity code",
)

# Call with set of files
group = parser.add_argument_group(
"Providing individual PEtab tables *DEPRECATED*. "
"Pass a PEtab yaml file instead."
)

group.add_argument(
"-s", "--sbml", dest="sbml_file_name", help="SBML model filename"
)
group.add_argument(
"-m",
"--measurements",
dest="measurement_file_name",
help="Measurement table",
)
group.add_argument(
"-c",
"--conditions",
dest="condition_file_name",
help="Conditions table",
)
group.add_argument(
"-p",
"--parameters",
dest="parameter_file_name",
help="Parameter table",
)
group.add_argument(
"-b",
"--observables",
dest="observable_file_name",
help="Observable table",
)

parser.add_argument(
"-y",
"--yaml",
dest="yaml_file_name_deprecated",
help="PEtab YAML problem filename. *DEPRECATED* Pass the YAML file "
"as positional argument instead.",
)

parser.add_argument(
dest="yaml_file_name",
help="PEtab YAML problem filename.",
Expand All @@ -115,42 +72,8 @@
)

args = parser.parse_args()
if any(
[
args.sbml_file_name,
args.condition_file_name,
args.observable_file_name,
args.measurement_file_name,
args.parameter_file_name,
]
):
print(
"WARNING: Passing individual tables to amico_import_petab is "
"deprecated, please pass a PEtab YAML file instead."
)
if (
not args.yaml_file_name and not args.yaml_file_name_deprecated
) and not all(
(
args.sbml_file_name,
args.condition_file_name,
args.observable_file_name,
args.measurement_file_name,
args.parameter_file_name,
)
):
parser.error(
"When not specifying a model name or YAML file, then "
"SBML, condition, observable, measurement and parameter file must "
"be specified."
)

if args.yaml_file_name_deprecated:
print(
"WARNING: -y/--yaml is deprecated. Pass the YAML file as "
"positional argument instead."
)
args.yaml_file_name = args.yaml_file_name_deprecated
if not args.yaml_file_name:
parser.error("Missing PEtab yaml file.")

Check warning on line 76 in python/sdist/amici/petab/cli/import_petab.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/petab/cli/import_petab.py#L75-L76

Added lines #L75 - L76 were not covered by tests

return args

Expand All @@ -162,18 +85,7 @@
"""
args = _parse_cli_args()

if args.yaml_file_name:
pp = petab.Problem.from_yaml(args.yaml_file_name)
else:
pp = petab.Problem(
model=SbmlModel.from_file(args.sbml_file_name),
condition_df=petab.get_condition_df(args.condition_file_name),
measurement_df=petab.get_measurement_df(
args.measurement_file_name
),
parameter_df=petab.get_parameter_df(args.parameter_file_name),
observable_df=petab.get_observable_df(args.observable_file_name),
)
pp = petab.Problem.from_yaml(args.yaml_file_name)

Check warning on line 88 in python/sdist/amici/petab/cli/import_petab.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/petab/cli/import_petab.py#L88

Added line #L88 was not covered by tests

# Check for valid PEtab before potentially modifying it
if args.validate:
Expand Down
16 changes: 4 additions & 12 deletions python/sdist/amici/petab/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import tempfile
from itertools import chain
from pathlib import Path
from typing import Union

import amici
import libsbml
Expand Down Expand Up @@ -215,7 +214,6 @@

@log_execution_time("Importing PEtab model", logger)
def import_model_sbml(
sbml_model: Union[str, Path, "libsbml.Model"] = None,
petab_problem: petab.Problem = None,
model_name: str | None = None,
model_output_dir: str | Path | None = None,
Expand All @@ -231,10 +229,6 @@
"""
Create AMICI model from PEtab problem

:param sbml_model:
PEtab SBML model or SBML file name.
Deprecated, pass ``petab_problem`` instead.

:param petab_problem:
PEtab problem.

Expand Down Expand Up @@ -302,12 +296,10 @@
# Model name from SBML ID or filename
if model_name is None:
if not (model_name := petab_problem.model.sbml_model.getId()):
if not isinstance(sbml_model, str | Path):
raise ValueError(
"No `model_name` was provided and no model "
"ID was specified in the SBML model."
)
model_name = os.path.splitext(os.path.split(sbml_model)[-1])[0]
raise ValueError(

Check warning on line 299 in python/sdist/amici/petab/sbml_import.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/petab/sbml_import.py#L299

Added line #L299 was not covered by tests
"No `model_name` was provided and no model "
"ID was specified in the SBML model."
)

if model_output_dir is None:
model_output_dir = os.path.join(
Expand Down
Loading