From 0137b1ebcf77322191d9bd0ac8a5b56a2f85d79d Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 14 Jul 2025 07:38:31 +0200 Subject: [PATCH] Fix `v2.ProblemConfig.extension` type According to the current schema, `extensions` is `object` instead of `list`. --- petab/v2/petab1to2.py | 2 +- petab/v2/problem.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/petab/v2/petab1to2.py b/petab/v2/petab1to2.py index 3869307f..75823f15 100644 --- a/petab/v2/petab1to2.py +++ b/petab/v2/petab1to2.py @@ -280,7 +280,7 @@ def _update_yaml(yaml_config: dict) -> dict: yaml_config[v2.C.FORMAT_VERSION] = "2.0.0" # Add extensions - yaml_config[v2.C.EXTENSIONS] = [] + yaml_config[v2.C.EXTENSIONS] = {} # Move models and set IDs (filename for now) for problem in yaml_config[v2.C.PROBLEMS]: diff --git a/petab/v2/problem.py b/petab/v2/problem.py index f6ec9c6a..0667f640 100644 --- a/petab/v2/problem.py +++ b/petab/v2/problem.py @@ -846,7 +846,7 @@ def validate( validation_results = ValidationResultList() if self.config.extensions: - extensions = ",".join(e.name for e in self.config.extensions) + extensions = ",".join(self.config.extensions.keys()) validation_results.append( ValidationIssue( ValidationIssueSeverity.WARNING, @@ -1116,7 +1116,7 @@ def model_dump(self, **kwargs) -> dict[str, Any]: >>> p += core.Parameter(id="par", lb=0, ub=1) >>> pprint(p.model_dump()) {'conditions': [], - 'config': {'extensions': [], + 'config': {'extensions': {}, 'format_version': '2.0.0', 'parameter_file': None, 'problems': []}, @@ -1168,7 +1168,6 @@ class SubProblem(BaseModel): class ExtensionConfig(BaseModel): """The configuration of a PEtab extension.""" - name: str version: str config: dict @@ -1194,8 +1193,8 @@ class ProblemConfig(BaseModel): parameter_file: str | AnyUrl | None = None #: The list of problems in the configuration. problems: list[SubProblem] = [] - #: Extensiions used by the problem. - extensions: list[ExtensionConfig] = [] + #: Extensions used by the problem. + extensions: dict[str, ExtensionConfig] = {} def to_yaml(self, filename: str | Path): """Write the configuration to a YAML file.