Skip to content

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

Merged
FFroehlich merged 5 commits into
mainfrom
claude/v2-multi-model-split-validate-925f17
Oct 13, 2026
Merged

FFroehlich merged 5 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 don't resolve in another model (so extension mappings such as SciML's are kept);
    • 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 CheckUniquePrimaryKeys, CheckMappingTable, CheckUnusedExperiments and CheckUnusedConditions on the full problem, because the split drops unused entries and other models' mappings;
    • 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, if CheckAllParametersPresentInParameterTable is requested. The single-model extraneous-parameter check 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.16%. Comparing base (90f7068) to head (de633fa).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #537      +/-   ##
==========================================
+ Coverage   76.67%   77.16%   +0.49%     
==========================================
  Files          67       67              
  Lines        7516     7568      +52     
  Branches     1339     1349      +10     
==========================================
+ Hits         5763     5840      +77     
+ Misses       1262     1242      -20     
+ Partials      491      486       -5     

☔ 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,
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 065ac9c: CheckUniquePrimaryKeys and CheckMappingTable now run on the full problem and are skipped in the per-model pass.

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)
]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 065ac9c: the split now drops only mappings that resolve in another model; mappings to non-model entities such as net1.parameters are kept in every part.

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]:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 065ac9c: the unused-parameter check only runs if CheckAllParametersPresentInParameterTable is among the requested tasks.

@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

* Check unique IDs and the mapping table on the full problem, since the
  split drops unused entries and other models' mappings.
* Keep mappings to non-model entities (e.g., SciML) in every part.
* Only report unused parameters if parameter table checks are requested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FFroehlich
FFroehlich enabled auto-merge (squash) October 12, 2026 08:54
@FFroehlich
FFroehlich merged commit e46ef71 into main Oct 13, 2026
13 checks passed
@FFroehlich
FFroehlich deleted the claude/v2-multi-model-split-validate-925f17 branch October 13, 2026 16:26
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