Skip to content

v2: split and validate multi-model problems - #537

Open
FFroehlich wants to merge 3 commits into
mainfrom
claude/v2-multi-model-split-validate-925f17
Open

FFroehlich wants to merge 3 commits into
mainfrom
claude/v2-multi-model-split-validate-925f17

Conversation

@FFroehlich

@FFroehlich FFroehlich commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #392.

PEtab v2 problems can have more than one model. So far Problem.validate() only warned about this, and every task that touches Problem.model failed. As a result, validate().has_errors() was always true for such problems.

Changes

  • New Problem.split_by_model() -> dict[str, Problem]. It returns one single-model problem per model, containing:

    • that model's measurements;
    • the experiments and conditions they reference;
    • the measured observables;
    • the mappings that resolve in that model;
    • the shared parameters that are valid for that model.

    It raises on duplicate model IDs and on measurements that aren't assigned to a model. With a single model, modelId stays optional.

  • Problem.validate() on multi-model problems:

    • checks the model IDs (CheckMeasurementModelId, duplicate model IDs) on the full problem and stops there if they're invalid;
    • runs CheckUnusedExperiments and CheckUnusedConditions on the full problem, because the split drops unused entries;
    • runs the remaining tasks on each part, and prefixes each issue's message with Model `<id>`: ;
    • reports parameters that no model uses as an error. This replaces the single-model extraneous-parameter check, which can't see them after the split.
  • Problem.__str__ no longer raises for multi-model problems.

  • Problem.add_measurement(..., model_id=...).

Downstream: pyPESTO ICB-DCM/pyPESTO#1772 adds multi-model PEtab v2 support. It currently carries its own copies of these helpers (split_petab_problem_by_model, _validate_petab_v2_problem), which it can drop once this is released.

🤖 Generated with Claude Code

Add `Problem.split_by_model`, which returns one single-model problem per
model with the measurements, experiments, conditions, observables,
mappings and parameters that model needs.

`Problem.validate` now handles problems with more than one model: it
checks the measurements' model IDs on the full problem, validates each
part of the split and reports parameters that no model uses. Issues
from a part are prefixed with its model ID.

Also fix `Problem.__str__` for multi-model problems and add `model_id`
to `Problem.add_measurement`.

Closes #392.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.22%. Comparing base (402393d) to head (19baaff).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #537      +/-   ##
==========================================
+ Coverage   76.77%   77.22%   +0.45%     
==========================================
  Files          67       67              
  Lines        7547     7597      +50     
  Branches     1346     1355       +9     
==========================================
+ Hits         5794     5867      +73     
+ Misses       1259     1240      -19     
+ Partials      494      490       -4     

☔ 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.

FFroehlich and others added 2 commits October 10, 2026 09:37
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FFroehlich
FFroehlich marked this pull request as ready for review October 10, 2026 08:43
@FFroehlich
FFroehlich requested a review from a team as a code owner October 10, 2026 08:43
Copilot AI balanced review requested due to automatic review settings October 10, 2026 08:43

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

Whole-table checks and extension mappings can be lost during splitting, producing incorrect validation results.

3 open findings
What changed in this PR

Adds multi-model splitting and validation support for PEtab v2 problems.

Changes:

  • Adds Problem.split_by_model() and model-aware validation.
  • Supports model IDs when adding measurements.
  • Adds multi-model regression tests.
File Description
petab/​v2/​core.py Implements splitting, validation, and measurement model IDs.
tests/​v2/​test_core.py Tests multi-model splitting and validation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread petab/v2/core.py
Comment on lines +2076 to +2079
full_problem_task_types = (
CheckUnusedExperiments,
CheckUnusedConditions,
)
Comment thread petab/v2/core.py
Comment on lines +2183 to +2188
[
m
for m in self.mappings
if m.model_id is None
or model.has_entity_with_id(m.model_id)
]
Comment thread petab/v2/core.py
Comment on lines +2102 to +2106
# extraneous parameters are dropped by the split
used_parameter_ids = set().union(
*(sub_problem.x_ids for sub_problem in sub_problems.values())
)
if unused := [x for x in self.x_ids if x not in used_parameter_ids]:

@dweindl dweindl 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.

Great, thanks

This branch has not been deployed

No deployments
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.

v2: Handle multi-model problems

4 participants