Skip to content

Commit

Permalink
handle PEtab v2 + multilanguage
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Jul 11, 2022
1 parent 6acd264 commit 815ef03
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions petab/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,12 @@ def from_yaml(yaml_config: Union[Dict, Path, str]) -> 'Problem':
'Consider using '
'petab.CompositeProblem.from_yaml() instead.')

if yaml_config[FORMAT_VERSION] != format_version.__format_version__:
raise ValueError("Provided PEtab files are of unsupported version"
if yaml_config[FORMAT_VERSION] not in {"1", 1, "1.0.0", "2.0.0"}:
raise ValueError("Provided PEtab files are of unsupported version "
f"{yaml_config[FORMAT_VERSION]}. Expected "
f"{format_version.__format_version__}.")
if yaml_config[FORMAT_VERSION] == "2.0.0":
warn("Support for PEtab2.0 is experimental!")

problem0 = yaml_config['problems'][0]

Expand Down Expand Up @@ -248,11 +250,14 @@ def from_yaml(yaml_config: Union[Dict, Path, str]) -> 'Problem':
# TODO https://github.com/PEtab-dev/libpetab-python/issues/6
raise NotImplementedError(
'Support for multiple models is not yet implemented.')
model_id, model_info = next(iter(problem0[MODEL_FILES].items()))
model = model_factory(get_path(model_info[MODEL_LOCATION]),
model_info[MODEL_LANGUAGE],
model_id=model_id) \
if problem0[SBML_FILES] else None
if not problem0[MODEL_FILES]:
model = None
else:
model_id, model_info = \
next(iter(problem0[MODEL_FILES].items()))
model = model_factory(get_path(model_info[MODEL_LOCATION]),
model_info[MODEL_LANGUAGE],
model_id=model_id)

measurement_files = [
get_path(f) for f in problem0.get(MEASUREMENT_FILES, [])]
Expand Down

0 comments on commit 815ef03

Please sign in to comment.