Skip to content

Commit 50994b2

Browse files
authored
Fix v2.ProblemConfig.extension type (#403)
According to the current schema, `extensions` is `object` instead of `list`.
1 parent 6a55afc commit 50994b2

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

petab/v2/petab1to2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def _update_yaml(yaml_config: dict) -> dict:
280280
yaml_config[v2.C.FORMAT_VERSION] = "2.0.0"
281281

282282
# Add extensions
283-
yaml_config[v2.C.EXTENSIONS] = []
283+
yaml_config[v2.C.EXTENSIONS] = {}
284284

285285
# Move models and set IDs (filename for now)
286286
for problem in yaml_config[v2.C.PROBLEMS]:

petab/v2/problem.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def validate(
846846

847847
validation_results = ValidationResultList()
848848
if self.config.extensions:
849-
extensions = ",".join(e.name for e in self.config.extensions)
849+
extensions = ",".join(self.config.extensions.keys())
850850
validation_results.append(
851851
ValidationIssue(
852852
ValidationIssueSeverity.WARNING,
@@ -1116,7 +1116,7 @@ def model_dump(self, **kwargs) -> dict[str, Any]:
11161116
>>> p += core.Parameter(id="par", lb=0, ub=1)
11171117
>>> pprint(p.model_dump())
11181118
{'conditions': [],
1119-
'config': {'extensions': [],
1119+
'config': {'extensions': {},
11201120
'format_version': '2.0.0',
11211121
'parameter_file': None,
11221122
'problems': []},
@@ -1168,7 +1168,6 @@ class SubProblem(BaseModel):
11681168
class ExtensionConfig(BaseModel):
11691169
"""The configuration of a PEtab extension."""
11701170

1171-
name: str
11721171
version: str
11731172
config: dict
11741173

@@ -1194,8 +1193,8 @@ class ProblemConfig(BaseModel):
11941193
parameter_file: str | AnyUrl | None = None
11951194
#: The list of problems in the configuration.
11961195
problems: list[SubProblem] = []
1197-
#: Extensiions used by the problem.
1198-
extensions: list[ExtensionConfig] = []
1196+
#: Extensions used by the problem.
1197+
extensions: dict[str, ExtensionConfig] = {}
11991198

12001199
def to_yaml(self, filename: str | Path):
12011200
"""Write the configuration to a YAML file.

0 commit comments

Comments
 (0)