Repository navigation
ExperimentsToSbmlConverter: keep per-experiment constants in the condition table - #579
Merged
FFroehlich merged 5 commits intoNov 25, 2026
Merged
Conversation
…n table A change that sets a constant model parameter to a number at the start of an experiment, where nothing else assigns that parameter, is constant per experiment, like a column of a PEtab v1 condition table. Encoding it in the model added a branch per experiment to the parameter's initial assignment and an indicator parameter per experiment. Froehlich_CellSystems2018 has 9169 experiments that each set 145 such parameters: 145 piecewise initial assignments with about 9169 branches each, which AMICI takes hours to import. These changes now stay as conditions of the experiment's kept periods (both of them with pre-equilibration, since the value persists), and an experiment gets an indicator only if it has a change encoded in the model. AMICI already sets every remaining condition target as a fixed parameter per experiment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgN92Vr4NPT21RjToXf6GS
… too A species set to a number at the start of an experiment, and nowhere else, is a per-experiment constant as well: Froehlich_CellSystems2018 sets the initial amounts of 23 species per cell line, which stayed piecewise initial assignments with ~9169 branches each. Such a species now gets a parameter `_petab_initial_value_<id>` holding its initial value and the initial assignment `<id> = _petab_initial_value_<id>`, and its changes are kept as changes of that parameter. Only species whose initial value is a number (after substituting compartment sizes that nothing changes) qualify, and only species that conditions actually set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgN92Vr4NPT21RjToXf6GS
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #579 +/- ##
==========================================
+ Coverage 80.18% 80.34% +0.15%
==========================================
Files 70 70
Lines 8443 8505 +62
Branches 1544 1561 +17
==========================================
+ Hits 6770 6833 +63
+ Misses 1182 1180 -2
- Partials 491 492 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
FFroehlich
added a commit
to frohlich-lab/PEtab-MCP
that referenced
this pull request
Nov 7, 2026
libpetab 0.10.0's ExperimentsToSbmlConverter encodes every per-experiment constant as a branch of a piecewise initial assignment: for Froehlich_CellSystems2018 (9169 experiments, 145 targets each) the import never finished, and the builds that got through did not compile. PEtab-dev/libpetab-python#579 keeps them in the condition table, where AMICI sets them per experiment. Pinned to its head commit; back to a floor once a release has it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgN92Vr4NPT21RjToXf6GS
FFroehlich
added a commit
to frohlich-lab/PEtab-MCP
that referenced
this pull request
Nov 7, 2026
FFroehlich
added a commit
to frohlich-lab/gemot
that referenced
this pull request
Nov 7, 2026
frohlich-lab/PEtab-MCP#260 pins petab to PEtab-dev/libpetab-python#579: per-experiment constants stay in the condition table, and froehlich imports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgN92Vr4NPT21RjToXf6GS
dweindl
reviewed
Nov 9, 2026
…-sbml-condition-parameters Resolve the conflict in ExperimentsToSbmlConverter._convert_experiment: keep the lazily created experiment indicator from this branch and apply _petab_to_sbml_math from #595 to the target values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…symbol Address review comments on #579: * A species whose initial value depends on the size of its compartment is kept in the condition table only if that compartment is constant. Constant parameters and compartments can't be targets of rules or event assignments, so only initial assignments are checked for them. Species still don't have to be constant: conditions set their initial value, which is constant per experiment even if the species changes during the simulation, and unchanging species are often not marked as constant (Antimony writes constant="false" for boundary species). * Use `petab_symbol` instead of `sp.Symbol` in the converter. * Test non-constant parameters and compartments, species with a rate rule or an event assignment, and species whose initial value is converted between amount and concentration. * Add changelog entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FFroehlich
added a commit
to frohlich-lab/PEtab-MCP
that referenced
this pull request
Nov 25, 2026
…s` group PyPI refuses a package whose Requires-Dist has a direct URL reference. - petab: `petab>=0.10.0`. The PEtab-dev/libpetab-python#579 commit moves to the group; without it Froehlich_CellSystems2018 does not import. - pysb: `pysb>=1.17`. 1.17.0 itself caps sympy<1.12 against amici's >=1.12.1, so an install without the group fails to resolve on that conflict; the master commit with pysb#611 (reported as 1.17.0+6.g9fc6bcb) satisfies the floor. - `[dependency-groups] pins` holds both commits; dependency groups are not published. CI and the README install with `--group pins` (pip >= 25.1). `allow-direct-references` is gone, so hatchling refuses a direct reference added to the dependencies again. Downstream: gemot installs this package by commit and has to name both commits itself once its pin passes this one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As suggested in review, keep the changes of a species in the condition table only if the species is constant, like for parameters. Constant species can't be targets of rules or event assignments, so only initial assignments need to be checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FFroehlich
added a commit
to frohlich-lab/PEtab-MCP
that referenced
this pull request
Nov 25, 2026
…ed metadata (#370) * README disclaimer; PyPI release workflow; version read from __version__ - README: a Disclaimer section under the badges. - .github/workflows/release.yml: builds the sdist and wheel, runs twine check, and uploads by trusted publishing from the `pypi` environment; a published release goes to PyPI, a manual run to TestPyPI. - pyproject.toml: the version is read from `petab_mcp.__version__`, so a bump edits one line. PyPI still refuses the upload while petab and pysb are pinned to git commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Published metadata without direct references: git pins move to a `pins` group PyPI refuses a package whose Requires-Dist has a direct URL reference. - petab: `petab>=0.10.0`. The PEtab-dev/libpetab-python#579 commit moves to the group; without it Froehlich_CellSystems2018 does not import. - pysb: `pysb>=1.17`. 1.17.0 itself caps sympy<1.12 against amici's >=1.12.1, so an install without the group fails to resolve on that conflict; the master commit with pysb#611 (reported as 1.17.0+6.g9fc6bcb) satisfies the floor. - `[dependency-groups] pins` holds both commits; dependency groups are not published. CI and the README install with `--group pins` (pip >= 25.1). `allow-direct-references` is gone, so hatchling refuses a direct reference added to the dependencies again. Downstream: gemot installs this package by commit and has to name both commits itself once its pin passes this one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
dweindl
approved these changes
Nov 25, 2026
FFroehlich
deleted the
claude/experiments-to-sbml-condition-parameters
branch
November 25, 2026 20:19
dweindl
added a commit
to AMICI-dev/AMICI
that referenced
this pull request
Nov 26, 2026
PEtab-dev/libpetab-python#579 changed `ExperimentsToSbmlConverter` in a way that breaks the JAX backend for converted PEtab v2 problems, so all CI runs fail since then (notebooks/docs, PEtab v2 test suite, PEtab SciML test suite and benchmarks). The fix is #3623. Until it is merged, pin libpetab to the commit before #579 (bd7151341). libpetab main has no other commits since. #3623 needs to revert this pin. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
dweindl
added a commit
to dweindl/AMICI
that referenced
this pull request
Nov 26, 2026
PEtab-dev/libpetab-python#579 changed `ExperimentsToSbmlConverter` to create the experiment indicator condition only for experiments with changes encoded in the model. Converted periods may then have no experiment-specific condition ids, and different experiments may refer to the same conditions. `JAXProblem` identified periods and matched them to the original periods by condition ids, which failed with `ValueError: Experiment '__default__' has no dynamic period with a condition id` and, for PEtab SciML problems, used array inputs of the wrong experiment. Identify periods by `(experiment, is_preequilibration)` and match converted to original experiments by experiment id. Update the JAX PEtab example notebook to identify experiments by `experiment_ids`. `JAXProblem.load_reinitialisation` now takes `(experiment, is_preeq)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dweindl
added a commit
to dweindl/AMICI
that referenced
this pull request
Nov 26, 2026
Revert e5c0a26 (AMICI-dev#3628), now that the JAX backend works with PEtab-dev/libpetab-python#579. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dweindl
added a commit
to dweindl/AMICI
that referenced
this pull request
Nov 27, 2026
…ter change (AMICI-dev#3623) PEtab-dev/libpetab-python#579 (merged 2026-11-25) changed `ExperimentsToSbmlConverter`: an experiment only gets its indicator condition `_petab_experiment_condition_<id>` if one of its changes is encoded in the model. Since then, all CI runs fail (Documentation/notebooks, PEtab v2 test suite, PEtab SciML test suite and benchmarks); `main` will fail as well on its next run: * Experiments whose converted periods have no condition ids (e.g., `__default__` from PEtab v1 problems without conditions): `ValueError: Experiment '__default__' has no dynamic period with a condition id.` * PEtab SciML test case `015`: all experiments' converted periods only refer to `_petab_preequilibration_off`. `JAXProblem._find_unconverted_period` matched converted to original periods by condition ids, so `e2` was mapped to `e1`'s original period, and the array inputs of `cond1` were used for both experiments. This gave a wrong likelihood (-5949.6 instead of 68.97) without an error. Converted condition ids don't identify a period anymore, and upcoming libpetab changes will make that more common. The converter keeps the experiment ids, the preequilibration period, and the first dynamic period. So periods are now identified by `(experiment, is_preequilibration)`, and converted periods are matched to the original ones by experiment id: * `_find_unconverted_period`, `_conditions_defining_changes`, `_condition_reinit_target_value`, `_state_needs_reinitialisation`, `_state_reinitialisation_value`, `_eval_nn` and `load_reinitialisation` take the experiment and the period type instead of condition ids. `_prepare_experiments` no longer takes condition ids. * `_find_unconverted_period` raises if the original problem has no experiment with the given id, instead of silently falling back to the converted conditions. * `_get_period_condition_ids` returns an empty tuple for a period without condition ids, and only raises if there is no such period. * Array inputs of neural networks are looked up by the first original condition id of the period that has array inputs. * In `run_simulations`, neural network outputs used as initial values are evaluated for the first dynamic period of an experiment instead of the last one. For converted problems, these are the same. * The JAX PEtab example notebook identifies experiments by `experiment_ids` instead of converted condition ids. Verified locally with libpetab main (bacc68669): `test_jax.py`, `test_petab_v2.py`, the PEtab SciML test suite and the JAX PEtab example notebook pass (case `015` and the three `test_petab_v2.py` JAX tests failed before; they passed with libpetab bd7151341, the commit before AMICI-dev#579). API changes: `JAXProblem.load_reinitialisation` now takes `(experiment, is_preeq)` instead of condition ids. For converted problems, `dynamic_conditions` in the results of `run_simulations` doesn't necessarily identify an experiment anymore; use `experiment_ids`. Also reverts the libpetab pin from AMICI-dev#3628. Relates to PEtab-dev/libpetab-python#630, which affects the converted problem itself. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ExperimentsToSbmlConverterencodes every change made at the start of an experiment in the model. Each experiment gets an indicator parameter, and each changed target gets one initial assignment of the formPiecewise((v_1, ind_1 > 0.5), ..., (v_n, ind_n > 0.5), (default, True)). Since #546 that piecewise is flat, but it still has one branch per experiment.Froehlich_CellSystems2018, upgraded to v2, has 9169 experiments. Each has a single period that sets 145 targets: 122 parameters and 23 species, the gene expression levels, mutation status and initial protein amounts of a cell line. That is 1,329,505 changes, which become 9169 indicator parameters and 145 initial assignments of about 9169 branches each. With libpetab 0.10.0, pyPESTO's
PetabImporteron this problem was still in_create_initial_assignmentsafter 1 h 43 min and had not reached AMICI. On a reduced model whose targets are all parameters, AMICI's import then took more than 2 h on one core, and the generated code did not compile. Imported as PEtab v1, AMICI imports and generates code for the same model in 917 s.Change
A change now stays in the condition table if it sets a condition parameter: a per-experiment constant, like a column of a PEtab v1 condition table. A target qualifies if:
Changes of non-constant parameters and species are still encoded in the model. Note that Antimony writes
constant="false"even for boundary species, so their changes are encoded too. In Froehlich_CellSystems2018, every species that the conditions set is constant.A parameter's changes are kept as they are. A species gets a parameter
_petab_initial_value_<id>that holds its initial value, and the initial assignment<id> = _petab_initial_value_<id>. Its changes become changes of that parameter.The kept changes go into the experiment's indicator condition (
_petab_experiment_condition_<id>), which both kept periods reference. So a value set in pre-equilibration persists into the main period, as it would in the model.An experiment now gets an indicator parameter only if one of its changes is encoded in the model, as an initial assignment branch or an event. For Froehlich, no indicators and no piecewise assignments remain: 23 initial assignments of the form above, and conversion takes 97 s.
AMICI needs no change. Its v2 importer already makes every remaining condition target a fixed parameter (
_do_import_sbml), andExperimentManager._set_constantssets those per experiment and period.The converter's output contract changes: a consumer now has to apply all changes of the kept periods, not just the indicators. The class docstring says so.
_simulateintests/v2/test_assignments_to_experiments.pysimulated the converted model by setting only the indicator; it now applies the kept conditions, as AMICI does. There is no opt-out flag; one could be added if a consumer needs everything encoded in the model. The changelog lists this as a breaking change, and the speed-up under performance.Verification
New tests in
tests/v2/test_converters.py:test_initial_assignments_many_experimentsnow also changesAin a later period, soAstill gets the flat piecewise that test is about.pytest tests, after mergingmain: 805 passed, 7 skipped. The pre-commit hooks (includingruff checkandruff format) are clean.Froehlich_CellSystems2018, rechecked after the review changes: upgraded with
petab1to2and converted, it has no indicators, piecewise initial assignments or events left.The AMICI runs below were done before the review changes (constant species and compartments,
petab_symbol).AMICI on the benchmark collection (AMICI 1.2.0, nominal parameters). Each model was imported and simulated as v1, as v2 with libpetab 0.10.0, and as v2 with this branch; AMICI did all the evaluation. Problems with timepoint-specific overrides were flattened the same way for all three when AMICI required it (Fiedler).
SBMLException, and Armistead_CellDeathDis2024 segfaults during AMICI's v2 code generation.petab1to2and AMICI's v2 import, not from this change.A small problem through AMICI, with both libpetab versions. It covers condition parameters, a species set per experiment, a species changed alongside to an expression, pre-equilibration, and a parameter changed by an event. Log-likelihood −12299.399748 vs −12299.399747; outputs agree within solver tolerance. The patched model needs 3 indicators instead of 23.
Froehlich_CellSystems2018 through pyPESTO and AMICI, with this branch:
ExpDatas, which is a separate AMICI issue: PEtab v2 ExperimentManager: create_edatas is quadratic in the number of parameters (list membership in apply_parameters) AMICI-dev/AMICI#3519.🤖 Generated with Claude Code
https://claude.ai/code/session_01JgN92Vr4NPT21RjToXf6GS