Skip to content

Commit

Permalink
Add get_problem_yaml_path
Browse files Browse the repository at this point in the history
Sometimes we want to have just the path instead of a petab.Problem.
  • Loading branch information
dweindl committed Jun 29, 2024
1 parent f18ed73 commit 9bc6260
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/python/benchmark_models_petab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
Python tool to access the model collection.
"""

from .base import get_problem
from .base import get_problem, get_problem_yaml_path
from .C import MODEL_DIRS, MODELS, MODELS_DIR
from .version import __version__
18 changes: 16 additions & 2 deletions src/python/benchmark_models_petab/base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
"""Get a petab problem from the collection."""

import os
from pathlib import Path

import petab

from .C import MODELS_DIR


def get_problem_yaml_path(id_: str) -> Path:
"""Get the path to the PEtab problem YAML file.
Parameters
----------
id_: Problem name, as in `benchmark_models_petab.MODELS`.
Returns
-------
The path to the PEtab problem YAML file.
"""
return Path(MODELS_DIR, id_, id_ + ".yaml")


def get_problem(id_: str) -> petab.Problem:
"""Read PEtab problem from benchmark collection by name.
Expand All @@ -18,6 +32,6 @@ def get_problem(id_: str) -> petab.Problem:
-------
The PEtab problem.
"""
yaml_file = os.path.join(MODELS_DIR, id_, id_ + ".yaml")
yaml_file = get_problem_yaml_path(id_)
petab_problem = petab.Problem.from_yaml(yaml_file)
return petab_problem

0 comments on commit 9bc6260

Please sign in to comment.