Repository navigation
petab1to2: allow skipping validation - #534
Merged
Merged
Conversation
Add a keyword-only `validate` argument to `petab1to2` and `petab_files_1to2`. With `validate=False`, neither the PEtab v1 input nor the generated PEtab v2 problem is linted, so problems that fail linting for reasons unrelated to the conversion (e.g., a visualization table referencing a non-existent datasetId, or an intentionally incomplete model) can still be converted. The default behaviour is unchanged. The YAML file is still validated against the v1 schema. Closes #528 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #534 +/- ##
==========================================
+ Coverage 76.50% 76.63% +0.12%
==========================================
Files 67 67
Lines 7526 7529 +3
Branches 1341 1342 +1
==========================================
+ Hits 5758 5770 +12
+ Misses 1269 1262 -7
+ Partials 499 497 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Regression coverage does not verify that disabling validation also skips post-conversion linting.
1 open finding
What changed in this PR
Adds an opt-out for linting during PEtab v1-to-v2 conversion, addressing #528 while preserving default validation.
Changes:
- Adds keyword-only
validate=Trueto both conversion functions. - Skips both lint steps when disabled, while retaining YAML schema validation.
- Adds conversion tests using invalid visualization data.
| File | Description |
|---|---|
| tests/v2/test_conversion.py | Tests default rejection and opt-out conversion in both output modes. |
| petab/v2/petab1to2.py | Implements and documents optional linting. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Comment on lines
+103
to
+111
| problem = petab1to2(yaml_file, validate=False) | ||
| assert isinstance(problem, Problem) | ||
| assert len(problem.measurements) == 2 | ||
|
|
||
| output_dir = tmp_path / "v2" | ||
| output_dir.mkdir() | ||
| petab1to2(yaml_file, output_dir, validate=False) | ||
| problem = Problem.from_yaml(output_dir / Path(yaml_file).name) | ||
| assert len(problem.measurements) == 2 |
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
…b1to2-validate-740e55 # Conflicts: # tests/v2/test_conversion.py
…ate-740e55' into claude/issue-528-petab1to2-validate-740e55
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.

petab1to2refuses to convert any PEtab v1 problem that does not passv1.lint_problem, even when the lint errors have nothing to do with the conversion. Examples are a visualization table that references adatasetIdmissing from the measurement table (Isensee_JCB2018, Schwen_PONE2014) and a model that is incomplete on purpose.This PR adds a keyword-only
validate: bool = Trueargument topetab1to2andpetab_files_1to2:validate=True(default): behaviour is unchanged. The v1 problem is linted before the conversion and the generated v2 problem after it, and either failure raisesValueError.validate=False: both lint steps are skipped. The v1 YAML file is still checked against the v1 schema, since the converter relies on its structure. The docstring recommends checking the result separately, e.g. withpetablint.I skipped the post-conversion v2 lint as well, rather than only downgrading it. A problem that fails v1 lint usually fails v2 lint for the same reason (e.g. an incomplete model), so keeping that check would defeat the opt-out.
Because the new parameter would shadow the imported
petab.v1.yaml.validate, that import is now aliased asvalidate_yaml.There is no CLI entry point for the converter, so no CLI flag was needed.
Not done: only warning about visualization-table errors by default. The issue also suggests this alternative. It would be simple, since the converter drops the visualization table anyway (PEtab v2 has no
visualization_files). However, it changes the default behaviour, so I left it out of this PR. It could be added on top if wanted.Tests
test_petab1to2_validate: a v1 problem whose only lint error is a stale visualizationdatasetIdstill raises by default. Withvalidate=Falseit converts, both to aProblemand to an output directory.pytest tests/v2: 78 passed, 1 skipped (benchmark_models_petabnot installed locally).validate=False. A v1 problem with an empty SBML model also converts withvalidate=False.Closes #528
🤖 Generated with Claude Code