Skip to content

petab1to2: allow skipping validation - #534

Merged
FFroehlich merged 4 commits into
mainfrom
claude/issue-528-petab1to2-validate-740e55
Oct 8, 2026
Merged

FFroehlich merged 4 commits into
mainfrom
claude/issue-528-petab1to2-validate-740e55

Conversation

@FFroehlich

Copy link
Copy Markdown
Collaborator

petab1to2 refuses to convert any PEtab v1 problem that does not pass v1.lint_problem, even when the lint errors have nothing to do with the conversion. Examples are a visualization table that references a datasetId missing from the measurement table (Isensee_JCB2018, Schwen_PONE2014) and a model that is incomplete on purpose.

This PR adds a keyword-only validate: bool = True argument to petab1to2 and petab_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 raises ValueError.
  • 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. with petablint.

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 as validate_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

  • New test_petab1to2_validate: a v1 problem whose only lint error is a stale visualization datasetId still raises by default. With validate=False it converts, both to a Problem and to an output directory.
  • pytest tests/v2: 78 passed, 1 skipped (benchmark_models_petab not installed locally).
  • The repro script from the issue converts with validate=False. A v1 problem with an empty SBML model also converts with validate=False.

Closes #528

🤖 Generated with Claude Code

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>
@FFroehlich
FFroehlich requested a review from a team as a code owner October 8, 2026 12:31
Copilot AI balanced review requested due to automatic review settings October 8, 2026 12:31
@codecov-commenter

codecov-commenter commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.63%. Comparing base (78dabf4) to head (bbed14b).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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=True to 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

@dilpath dilpath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread petab/v2/petab1to2.py Outdated
FFroehlich and others added 3 commits October 8, 2026 18:40
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
@FFroehlich
FFroehlich enabled auto-merge (squash) October 8, 2026 17:48
@FFroehlich
FFroehlich merged commit 921ce8e into main Oct 8, 2026
13 checks passed
@FFroehlich
FFroehlich deleted the claude/issue-528-petab1to2-validate-740e55 branch October 8, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

petab1to2: refuses problems that fail v1 lint for reasons unrelated to the conversion

4 participants