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 53e6bed
Showing 1 changed file with 16 additions and 2 deletions.
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 53e6bed

Please sign in to comment.