Skip to content

v2: parameter_file -> parameter_files #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions petab/schemas/petab_schema.v2.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ properties:
- type: integer
description: Version of the PEtab format

parameter_file:
oneOf:
- type: string
- type: array
parameter_files:
type: array
description: |
File name (absolute or relative) or URL to PEtab parameter table
containing parameters of all models listed in `problems`. A single
table may be split into multiple files and described as an array here.
List of PEtab parameter files.
items:
type: string
description: |
File name (absolute or relative) or URL to a PEtab parameter table.

model_files:
type: object
Expand Down Expand Up @@ -95,7 +95,7 @@ properties:

required:
- format_version
- parameter_file
- parameter_files
- model_files
- observable_files
- measurement_files
4 changes: 2 additions & 2 deletions petab/v2/C.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@
# YAML
#: PEtab version key in the YAML file
FORMAT_VERSION = "format_version"
#: Parameter file key in the YAML file
PARAMETER_FILE = "parameter_file"
#: Parameter files key in the YAML file
PARAMETER_FILES = "parameter_files"
#: Problems key in the YAML file
PROBLEMS = "problems"
#: Model files key in the YAML file
Expand Down
14 changes: 12 additions & 2 deletions petab/v2/petab1to2.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ def petab_files_1to2(yaml_config: Path | str, output_dir: Path | str):

# parameter table
parameter_df = v1v2_parameter_df(petab_problem.parameter_df.copy())
file = yaml_config[v2.C.PARAMETER_FILE]
v2.write_parameter_df(parameter_df, get_dest_path(file))
v2.write_parameter_df(
parameter_df, get_dest_path(new_yaml_config.parameter_files[0])
)

# copy files that don't need conversion
# (models, visualizations)
Expand Down Expand Up @@ -294,6 +295,15 @@ def _update_yaml(yaml_config: dict) -> dict:
if file_type in problem:
yaml_config[file_type] = problem[file_type]
del problem[file_type]
del yaml_config[v1.C.PROBLEMS]

# parameter_file -> parameter_files
if not isinstance(
(par_files := yaml_config.pop(v1.C.PARAMETER_FILE, [])), list
):
par_files = [par_files]
yaml_config[v2.C.PARAMETER_FILES] = par_files

return yaml_config


Expand Down
2 changes: 1 addition & 1 deletion petab/v2/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ class ProblemConfig(BaseModel):
# rename to parameter_files in yaml for consistency with other files?
# always a list?
parameter_files: list[str | AnyUrl] = Field(
default=[], alias=PARAMETER_FILE
default=[], alias=PARAMETER_FILES
)

# TODO: consider changing str to Path
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/test_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_problem_from_yaml_multiple_files():
"""
yaml_config = """
format_version: 2.0.0
parameter_file: []
parameter_files: []
condition_files: [conditions1.tsv, conditions2.tsv]
measurement_files: [measurements1.tsv, measurements2.tsv]
observable_files: [observables1.tsv, observables2.tsv]
Expand Down
Loading