Skip to content

Commit e7af530

Browse files
committed
Add id field to v2.ProblemConfig
* Update schema * v2.Problem.id * v2.ProblemConfig.id Related to PEtab-dev/PEtab#646. Closes #441.
1 parent f79bba5 commit e7af530

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

petab/schemas/petab_schema.v2.0.0.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ properties:
2323
- type: integer
2424
description: Version of the PEtab format
2525

26+
id:
27+
type: string
28+
description: |
29+
Identifier of the PEtab problem.
30+
31+
This is optional and has no effect on the PEtab problem itself.
32+
pattern: "^[a-zA-Z_]\\w*|^$"
33+
2634
parameter_files:
2735
type: array
2836
description: |

petab/v2/core.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,18 @@ def mappings(self) -> list[Mapping]:
16301630
chain.from_iterable(mt.mappings for mt in self.mapping_tables)
16311631
)
16321632

1633+
@property
1634+
def id(self) -> str:
1635+
"""The ID of the PEtab problem if set, ``None`` otherwise."""
1636+
return self.config.id if self.config else None
1637+
1638+
@id.setter
1639+
def id(self, value: str):
1640+
"""Set the ID of the PEtab problem."""
1641+
if self.config is None:
1642+
self.config = ProblemConfig(format_version="2.0.0")
1643+
self.config.id = value
1644+
16331645
def get_optimization_parameters(self) -> list[str]:
16341646
"""
16351647
Get the list of optimization parameter IDs from parameter table.
@@ -2327,6 +2339,10 @@ class ProblemConfig(BaseModel):
23272339
)
23282340
#: The PEtab format version.
23292341
format_version: str = "2.0.0"
2342+
2343+
#: The problem ID.
2344+
id: str = ""
2345+
23302346
#: The path to the parameter file, relative to ``base_path``.
23312347
# TODO https://github.com/PEtab-dev/PEtab/pull/641:
23322348
# rename to parameter_files in yaml for consistency with other files?

0 commit comments

Comments
 (0)