File tree Expand file tree Collapse file tree
src/python/benchmark_models_petab Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44Python tool to access the model collection.
55"""
66
7- from .base import get_problem
7+ from .base import get_problem , get_problem_yaml_path
88from .C import MODEL_DIRS , MODELS , MODELS_DIR
99from .version import __version__
Original file line number Diff line number Diff line change 11"""Get a petab problem from the collection."""
22
3- import os
3+ from pathlib import Path
44
55import petab
66
77from .C import MODELS_DIR
88
99
10+ def get_problem_yaml_path (id_ : str ) -> Path :
11+ """Get the path to the PEtab problem YAML file.
12+
13+ Parameters
14+ ----------
15+ id_: Problem name, as in `benchmark_models_petab.MODELS`.
16+
17+ Returns
18+ -------
19+ The path to the PEtab problem YAML file.
20+ """
21+ yaml_path = Path (MODELS_DIR , id_ , id_ + ".yaml" )
22+ if not yaml_path .exists ():
23+ yaml_path = Path (MODELS_DIR , id_ , "problem.yaml" )
24+ if not yaml_path .exists ():
25+ raise ValueError (f"Could not find YAML for problem with ID `{ id_ } `." )
26+ return yaml_path
27+
28+
1029def get_problem (id_ : str ) -> petab .Problem :
1130 """Read PEtab problem from benchmark collection by name.
1231
@@ -18,6 +37,6 @@ def get_problem(id_: str) -> petab.Problem:
1837 -------
1938 The PEtab problem.
2039 """
21- yaml_file = os . path . join ( MODELS_DIR , id_ , id_ + ".yaml" )
40+ yaml_file = get_problem_yaml_path ( id_ )
2241 petab_problem = petab .Problem .from_yaml (yaml_file )
2342 return petab_problem
You can’t perform that action at this time.
0 commit comments