Skip to content

Commit 815ef03

Browse files
committed
handle PEtab v2 + multilanguage
1 parent 6acd264 commit 815ef03

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

petab/problem.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ def from_yaml(yaml_config: Union[Dict, Path, str]) -> 'Problem':
217217
'Consider using '
218218
'petab.CompositeProblem.from_yaml() instead.')
219219

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

225227
problem0 = yaml_config['problems'][0]
226228

@@ -248,11 +250,14 @@ def from_yaml(yaml_config: Union[Dict, Path, str]) -> 'Problem':
248250
# TODO https://github.com/PEtab-dev/libpetab-python/issues/6
249251
raise NotImplementedError(
250252
'Support for multiple models is not yet implemented.')
251-
model_id, model_info = next(iter(problem0[MODEL_FILES].items()))
252-
model = model_factory(get_path(model_info[MODEL_LOCATION]),
253-
model_info[MODEL_LANGUAGE],
254-
model_id=model_id) \
255-
if problem0[SBML_FILES] else None
253+
if not problem0[MODEL_FILES]:
254+
model = None
255+
else:
256+
model_id, model_info = \
257+
next(iter(problem0[MODEL_FILES].items()))
258+
model = model_factory(get_path(model_info[MODEL_LOCATION]),
259+
model_info[MODEL_LANGUAGE],
260+
model_id=model_id)
256261

257262
measurement_files = [
258263
get_path(f) for f in problem0.get(MEASUREMENT_FILES, [])]

0 commit comments

Comments
 (0)