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

Deprecate passing individual tables to amici_import_petab #2464

Merged
merged 5 commits into from
Jun 26, 2024
Merged
Changes from 3 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
69 changes: 54 additions & 15 deletions python/sdist/amici/petab/cli/import_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import petab

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


def _parse_cli_args():
Expand Down Expand Up @@ -59,28 +60,33 @@
)

# Call with set of files
parser.add_argument(
group = parser.add_argument_group(

Check warning on line 63 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#L63

Added line #L63 was not covered by tests
"Providing individual PEtab tables *DEPRECATED*. "
"Pass a PEtab yaml file instead."
)

group.add_argument(

Check warning on line 68 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#L68

Added line #L68 was not covered by tests
"-s", "--sbml", dest="sbml_file_name", help="SBML model filename"
)
parser.add_argument(
group.add_argument(

Check warning on line 71 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#L71

Added line #L71 was not covered by tests
"-m",
"--measurements",
dest="measurement_file_name",
help="Measurement table",
)
parser.add_argument(
group.add_argument(

Check warning on line 77 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#L77

Added line #L77 was not covered by tests
"-c",
"--conditions",
dest="condition_file_name",
help="Conditions table",
)
parser.add_argument(
group.add_argument(

Check warning on line 83 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#L83

Added line #L83 was not covered by tests
"-p",
"--parameters",
dest="parameter_file_name",
help="Parameter table",
)
parser.add_argument(
group.add_argument(

Check warning on line 89 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#L89

Added line #L89 was not covered by tests
"-b",
"--observables",
dest="observable_file_name",
Expand All @@ -90,8 +96,15 @@
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(

Check warning on line 104 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#L104

Added line #L104 was not covered by tests
dest="yaml_file_name",
help="PEtab YAML problem filename",
help="PEtab YAML problem filename.",
nargs="?",
)

parser.add_argument(
Expand All @@ -102,18 +115,42 @@
)

args = parser.parse_args()
dweindl marked this conversation as resolved.
Show resolved Hide resolved

if not args.yaml_file_name and not all(
if any(

Check warning on line 118 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#L118

Added line #L118 was not covered by tests
[
args.sbml_file_name,
dweindl marked this conversation as resolved.
Show resolved Hide resolved
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 (

Check warning on line 131 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#L131

Added line #L131 was not covered by tests
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 and observable file must be specified"
"SBML, condition, observable, measurement and parameter file must "
"be specified."
)

if args.yaml_file_name_deprecated:
print(

Check warning on line 149 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#L148-L149

Added lines #L148 - L149 were not covered by tests
"WARNING: -y/--yaml is deprecated. Pass the YAML file as "
"positional argument instead."
)
args.yaml_file_name = args.yaml_file_name_deprecated

Check warning on line 153 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#L153

Added line #L153 was not covered by tests

return args

Expand All @@ -128,12 +165,14 @@
if args.yaml_file_name:
pp = petab.Problem.from_yaml(args.yaml_file_name)
else:
pp = petab.Problem.from_files(
sbml_file=args.sbml_file_name,
condition_file=args.condition_file_name,
measurement_file=args.measurement_file_name,
parameter_file=args.parameter_file_name,
observable_files=args.observable_file_name,
pp = petab.Problem(

Check warning on line 168 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#L168

Added line #L168 was not covered by tests
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),
)

# Check for valid PEtab before potentially modifying it
Expand Down