Repository navigation
Omit empty optional entries in ProblemConfig.to_yaml - #547
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #547 +/- ##
==========================================
+ Coverage 77.74% 77.77% +0.03%
==========================================
Files 67 67
Lines 7702 7708 +6
Branches 1378 1380 +2
==========================================
+ Hits 5988 5995 +7
Misses 1226 1226
+ Partials 488 487 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dweindl
marked this pull request as ready for review
October 15, 2026 08:51
dilpath
approved these changes
Oct 15, 2026
dilpath
left a comment
Member
There was a problem hiding this comment.
Looks good. Could also be covered by petab.v2.options but no need I think.
|
|
||
| # Omit empty optional entries. Required ones are kept even if empty. | ||
| for key in C.PROBLEM_CONFIG_OPTIONAL_KEYS: | ||
| # an empty `id` is invalid and must not be dropped silently |
Member
There was a problem hiding this comment.
Strange that the spec allows "empty" for the optional tables but not for the optional ID?
Member
Author
There was a problem hiding this comment.
Yeah, still some inconsistencies there..
Member
Author
Agreed |
`ProblemConfig.to_yaml` wrote `condition_files: []`,
`experiment_files: []`, `mapping_files: []` and `extensions: {}` when
these were not set. They are optional in the PEtab v2 schema, so leave
them out. Required entries are still written even when empty, so that a
schema violation stays visible.
This affects `Problem.to_files` and `petab1to2`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `PROBLEM_CONFIG_REQUIRED_KEYS`, `PROBLEM_CONFIG_OPTIONAL_KEYS` and `PROBLEM_ID`, and use them in `ProblemConfig.to_yaml`. A test checks that the lists match the PEtab v2 schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ProblemConfig.to_yamlwrotecondition_files: [],experiment_files: [],mapping_files: []andextensions: {}whenever these weren't set. The PEtab v2 schema doesn't require them. They add noise, and they make files written by libpetab differ from files written by hand to the spec. This affects everything that goes throughto_yaml, includingProblem.to_filesandpetab1to2.These four entries are now left out when they're empty. Required entries (
parameter_files,model_files,measurement_files,observable_files) are still written even when empty, so that a schema violation stays visible. Reading problems without these entries already worked, so only the writer changes.The required and optional keys are now available as
petab.v2.C.PROBLEM_CONFIG_REQUIRED_KEYSandpetab.v2.C.PROBLEM_CONFIG_OPTIONAL_KEYS. A test checks that they match the schema.🤖 Drafted with AI assistance (Claude Code)