Raise clear error for PEtab YAML with empty 'problems' section - #521
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #521 +/- ##
=======================================
Coverage 76.14% 76.15%
=======================================
Files 67 67
Lines 7526 7528 +2
Branches 1341 1342 +1
=======================================
+ Hits 5731 5733 +2
Misses 1294 1294
Partials 501 501 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`Problem.from_yaml` raised a raw `KeyError`/`IndexError` when the `problems` list was empty or absent (which pydantic silently defaults to an empty list), instead of a helpful message. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
dweindl
force-pushed
the
fix-218-missing-problems
branch
from
September 22, 2026 15:01
9537e00 to
764b2be
Compare
dweindl
marked this pull request as ready for review
September 22, 2026 16:04
dilpath
approved these changes
Sep 22, 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.
Fixes the remaining part of #218.
The originally reported
KeyError: 'parameter_file'no longer occurs, sinceProblem.from_yamlnow builds a pydanticProblemConfig, which already givesparameter_file/sbml_filessane defaults. However, the same class of problem still exists forproblems:ProblemConfig.problemsdefaults to[]when the key is missing from the YAML (or is given explicitly asproblems: []), andProblem.from_yamlthen indexes into it unconditionally (config.problems[0]), raising a rawIndexError(is_composite_problem()similarly raised a rawKeyErrorbeforehand).So this isn't really about a "missing" key — it's about an empty
problemssection, however it comes to be empty. This adds a clearValueErrorfor that case, and a parametrized regression test covering both the missing-key and explicit-empty-list cases.🤖 Generated with Claude Code