Skip to content

v2: faster model entity ID lookups for many IDs - #655

Open
dweindl wants to merge 1 commit into
PEtab-dev:mainfrom
dweindl:v2-model-id-perf
Open

dweindl wants to merge 1 commit into
PEtab-dev:mainfrom
dweindl:v2-model-id-perf

Conversation

@dweindl

@dweindl dweindl commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

CheckGloballyUniqueIds and ID generation in reparametrize_log checked each ID separately with has_entity_with_id, which for SBML models scans the whole model per call (~0.7 ms for Froehlich_CellSystems2018; ~25 s in total for the lint check and ~5 s for reparametrization). Both now use the new private Model._get_model_entity_checker. For SBML models, it collects all SBML IDs once and only calls has_entity_with_id for IDs that occur in the model, so the results don't change. Other model types use has_entity_with_id as before.

Collecting the IDs via getListOfAllElements takes ~0.4 s for Froehlich_CellSystems2018 and scales roughly quadratically with the model size, which pays off when many IDs are checked.

petab1to2 for Froehlich_CellSystems2018 takes ~20 s less (reparametrize="none": 38 s → 20 s, "all": 65 s → 40 s) with identical output.

Relates to #652.

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.45%. Comparing base (b694a77) to head (9e58eff).

Files with missing lines Patch % Lines
petab/v2/lint.py 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #655   +/-   ##
=======================================
  Coverage   81.45%   81.45%           
=======================================
  Files          76       76           
  Lines        8906     8917   +11     
  Branches     1631     1633    +2     
=======================================
+ Hits         7254     7263    +9     
- Misses       1171     1172    +1     
- Partials      481      482    +1     

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

`CheckGloballyUniqueIds` and ID generation in `reparametrize_log`
checked each ID with `has_entity_with_id`, which scans the whole SBML
model per call (~0.7 ms for Froehlich_CellSystems2018). Both now use the
new `Model._get_model_entity_checker`. For SBML models, it collects all
SBML IDs once and only calls `has_entity_with_id` for IDs that occur in
the model, so the results don't change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dweindl
dweindl marked this pull request as ready for review December 2, 2026 09:58
@dweindl
dweindl requested a review from a team as a code owner December 2, 2026 09:58
@dweindl
dweindl requested a review from PaulJonasJost December 2, 2026 09:58
@dweindl dweindl self-assigned this Dec 2, 2026

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