Skip to content

v2 lint: check model entities as condition targets and parameters - #623

Merged
dweindl merged 1 commit into
PEtab-dev:mainfrom
dweindl:model-entities
Dec 2, 2026
Merged

dweindl merged 1 commit into
PEtab-dev:mainfrom
dweindl:model-entities

Conversation

@dweindl

@dweindl dweindl commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Adds a new v2 validation task CheckModelEntityEligibility. It reports errors for model entities that the PEtab v2 specification does not allow as condition targets (e.g., targets of assignment rules) or in the parameter table (e.g., targets of rate rules or event assignments). IDs that CheckValidConditionTargets or CheckValidParameterInConditionOrParameterTable already reject are not reported again; models without entity classification are skipped. Mapping-table aliases are not resolved.

To support this, models can now classify their entities: what an entity is (model parameter, species, compartment, other quantity, non-quantity), whether its value is constant, differential, or algebraic, and whether it is event-assigned. This is private for now (petab._models._entities, Model._get_entity, Model._iter_entities) and implemented for SBML models; PySB and BNGL follow separately. The PEtab v2 rules on top of this classification live in petab/v2/lint.py. Variables determined by SBML algebraic rules are not detected yet.

Relates to #518 (first step: private entity classification).

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.27586% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.45%. Comparing base (560c374) to head (c5ba123).

Files with missing lines Patch % Lines
petab/_models/model.py 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #623      +/-   ##
==========================================
+ Coverage   81.20%   81.45%   +0.24%     
==========================================
  Files          75       76       +1     
  Lines        8793     8906     +113     
  Branches     1608     1631      +23     
==========================================
+ Hits         7140     7254     +114     
+ Misses       1172     1171       -1     
  Partials      481      481              

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

@dweindl dweindl self-assigned this Nov 25, 2026
@dweindl
dweindl force-pushed the model-entities branch 2 times, most recently from 32d4cd5 to bb736e1 Compare November 30, 2026 18:22
@dweindl
dweindl marked this pull request as ready for review November 30, 2026 18:27
@dweindl
dweindl requested a review from a team as a code owner November 30, 2026 18:27
@dweindl
dweindl requested a review from FFroehlich November 30, 2026 18:28
@dweindl dweindl added this to the v0.11.0 milestone Dec 1, 2026
Add a private classification of model entities
(`petab._models._entities`, `Model._get_entity`,
`Model._iter_entities`), implemented for SBML models: what an entity is
(parameter, species, compartment, other quantity, non-quantity), how its
value evolves (constant, differential, algebraic), and whether it is
the target of an event assignment.

Use it in the new v2 validation task `CheckModelEntityEligibility`,
which reports errors for entities that PEtab v2 does not allow as
condition targets or in the parameter table, e.g. targets of assignment
rules or event assignments. To avoid duplicate errors, it skips IDs
that `CheckValidConditionTargets` or
`CheckValidParameterInConditionOrParameterTable` already reject. Models
without classification support are skipped.

Relates to PEtab-dev#518.

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

dweindl commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

Also fixes SbmlModel.has_entity_with_id for the IDs of rules, initial assignments, and event assignments (SBML L3V2+). They share the namespace with all other SBML IDs, but getElementBySId does not find them, so collisions with PEtab IDs went undetected.

This will be handled by libsbml in its next release (sbmlteam/libsbml#526). Not adding the less efficient Python-handling here.

@dweindl
dweindl added this pull request to the merge queue Dec 2, 2026
Merged via the queue into PEtab-dev:main with commit b694a77 Dec 2, 2026
8 checks passed
@dweindl
dweindl deleted the model-entities branch December 2, 2026 09:00
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.

3 participants