Skip to content

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

Draft
dweindl wants to merge 4 commits into
PEtab-dev:mainfrom
dweindl:model-entities
Draft

dweindl wants to merge 4 commits 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 species changed by reactions) or in the parameter table (e.g., targets of assignment rules, rate rules, or event assignments), and warnings for questionable but valid uses. Mapping-table aliases are resolved; models without the required support are skipped.

To support this, models can now classify their entities: what an entity is (parameter, species, compartment, other quantity, non-quantity), how its value evolves (constant, differential, algebraic), and how its initial value is defined. This is private for now (petab._models._entities, Model._get_entity, Model._iter_entities) and implemented for SBML models; PySB and BNGL follow separately.

Depends on #622; only the commits after it belong to this PR.

🤖 Generated with Claude Code

dweindl and others added 4 commits November 23, 2026 14:33
Move the model implementation from `petab/v1/models` to
`petab/_models`, and the PySB and BNGL tests and fixtures from
`tests/v1` to `tests/models`, without changes; the imports are fixed in
the next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The model classes serve both PEtab v1 and v2, but lived in
`petab.v1.models`, with `petab.v2.models` re-exporting them. This
suggested that PySB and BNGL models were supported with PEtab v1.

Move the implementation to the private package `petab._models` (in the
previous commit; here, only imports change). `petab.v1.models` and
`petab.v2.models` re-export it. Deprecate (for now only in the changelog)
the PySB and BNGL modules in `petab.v1.models`.

Move the PySB and BNGL tests and fixtures to `tests/models`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 how the model
defines its initial value.

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, and warnings for questionable uses.
Models without classification support are skipped.

References PEtab-dev#518.

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.39826% with 125 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.76%. Comparing base (d21ee3b) to head (7023be0).

Files with missing lines Patch % Lines
petab/_models/pysb_model.py 79.88% 31 Missing and 4 partials ⚠️
petab/_models/sbml_model.py 89.55% 16 Missing and 17 partials ⚠️
petab/_models/bngl_model.py 85.80% 18 Missing and 5 partials ⚠️
petab/_models/model.py 69.56% 16 Missing and 5 partials ⚠️
petab/v1/models/bngl_model.py 0.00% 5 Missing ⚠️
petab/v1/models/pysb_model.py 0.00% 5 Missing ⚠️
petab/_models/_entities.py 98.23% 1 Missing and 1 partial ⚠️
petab/v2/lint.py 96.96% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #623      +/-   ##
==========================================
+ Coverage   80.18%   80.76%   +0.58%     
==========================================
  Files          70       76       +6     
  Lines        8442     8808     +366     
  Branches     1544     1614      +70     
==========================================
+ Hits         6769     7114     +345     
- Misses       1182     1193      +11     
- Partials      491      501      +10     

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

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.

2 participants