Repository navigation
Fix BasicSymbolic dispatch for SymbolicUtils v4 - #201
ChrisRackauckas merged 3 commits into
Conversation
SymbolicUtils v4 reworked `BasicSymbolic` so that the type parameter
must be a `<: SymbolicUtils.SymVariant` (`SymReal`, `SafeReal`, or
`TreeReal`); the value type (`Real`, `Bool`, …) lives on the value
and is queried via `SymbolicUtils.symtype(x)`. The four
`check_args(...)::BasicSymbolic{Real}` / `::BasicSymbolic{Bool}`
methods inside `get_massaction` therefore failed to load on
SymbolicUtils v4, with
TypeError: in typeof(BasicSymbolicImpl), in T,
expected T<:SymbolicUtils.SymVariant, got Type{Real}
at `src/reactions.jl:177`. This blocked precompilation of
SBMLToolkit, and AutoMerge for the v0.1.32 registration in
JuliaRegistries/General#154236 reported `import SBMLToolkit`
as failing.
Drop the `{Real}` / `{Bool}` parameter from the four signatures
and check the value type at runtime via `SymbolicUtils.symtype(x)`:
Bool symbolic expressions now route to the `NaN` branch from a
single entry point. The change is forward-compatible with v4 and
remains valid against SymbolicUtils v1-v3 (where the bare
`BasicSymbolic` abstract type still dispatches the same way).
Verified locally on Julia 1.10 with the project resolved to
SymbolicUtils v4.25.2 + ModelingToolkit v11.24.0:
- `using SBMLToolkit` precompiles and loads cleanly.
- `Pkg.test()`: 118/118 tests pass.
Co-Authored-By: Chris Rackauckas <[email protected]>
…m(::SBML.Model)` Catalyst v16 / ModelingToolkit v11 introduced three breaking changes that prevent SBMLToolkit from successfully constructing systems on the new ecosystem (the SymbolicUtils v4 fix in 2f65b7a only addressed precompilation): 1. `Catalyst.ReactionSystem` no longer accepts a single `defaults` kwarg. It is split into `bindings` (parameter values, validated to depend only on other parameters) and `initial_conditions` (state values at t=0, which may reference any symbolic value). 2. `convert(ODESystem, rs; ...)` is removed; `ODESystem` is now an `IntermediateDeprecationSystem` alias on MTK v11. The supported conversion entry point is `Catalyst.ode_model(rs; ...)`. 3. SymbolicUtils v4 dropped the `.arguments` struct field. Public accessor is `SymbolicUtils.arguments(x)`. This commit: - Splits SBML-derived defaults into `bindings`/`initial_conditions` and routes parameter assignments that reference species (e.g. `parameter S3 := k1 * S2` from SBML `initialAssignment`) to `initial_conditions` — Catalyst v16 `check_bindings` rejects non-parameter symbols in bindings, and `initial_conditions` preserves SBML's "evaluate once at t=0" semantics. - Replaces `convert(ODESystem, rs; ...)` with `Catalyst.ode_model(rs; ...)`. - Replaces `trigger.arguments` with `SymbolicUtils.arguments(trigger)` in event-trigger parsing. All three call sites are version-gated with `@static if pkgversion(Catalyst) >= v"16"` so the package keeps working with Catalyst v14/v15 + MTK v9. Verified locally on Julia 1.10 with the resolved stack SBMLToolkit (this branch) + Catalyst v16.1.1 + ModelingToolkit v11.24.1 + Sundials v6.1.0 against the SBMLToolkitTestSuite cases 00001-00500: 277 cases pass, 0 regressions and 0 improvements versus the main-branch baseline (which uses Catalyst v15 + MTK v9). The previously-passing cases 00507/00508/00509 (SBML `initialAssignment` on a parameter referencing a species) also continue to pass once the bindings/initial_conditions split is applied. Co-Authored-By: Chris Rackauckas <[email protected]>
|
Pushed an additional commit (d2dcf2c) on top of this branch with the remaining Catalyst v16 / ModelingToolkit v11 fixes. PR #201's existing fix only addressed the SymbolicUtils v4 precompile error — once SBMLToolkit's tests actually resolve to Catalyst v16 (rather than the v15 they fall back to via the
All three call sites are version-gated with Local verification (Julia 1.10 LTS, this branch dev'd into SBMLToolkitTestSuite, project resolved to Catalyst v16.1.1 + MTK v11.24.1 + Sundials v6.1.0): SBMLToolkitTestSuite |
Pre-existing CI red on this branch — Runic v1.7 wants a space around the `=` in keyword-argument syntax. Tooling-only change. Co-Authored-By: Chris Rackauckas <[email protected]>
…ystem The dependabot bump in #65 widened compat for ModelingToolkit (v11) and Sundials (v6), but the resulting stack is unreachable on the released SBMLToolkit v0.1.31 (which caps Catalyst at v15) and introduces breaking-change failures even once SBMLToolkit lands the corresponding fix (SciML/SBMLToolkit.jl#201). This commit makes the bump actually work end-to-end: Compat changes (vs. main): - Add `Catalyst = "14, 15, 16"` (and `[deps]` entry). The `verify_case` pipeline now invokes a Catalyst function directly, so the dep needs to be explicit rather than transitive via SBMLToolkit. - `ModelingToolkit = "8, 9, 11.24"` and `Sundials = "4, 6.1"` (kept from the dependabot bump in #65). These pull in MTK v11.24 and Sundials v6.1 once SBMLToolkit v0.1.32+ unlocks Catalyst v16. - Replace dependabot's `Downloads = "1.7.0"` with `Downloads = "1"`. Downloads is a Julia stdlib whose version tracks the Julia minor; pinning to 1.7.0 made the package only resolvable on Julia 1.11+. - `SBMLToolkit = "0.1.32"` (was `"0.1"`). The Catalyst v16 / MTK v11 fixes land in 0.1.32 — older SBMLToolkit precompilation breaks under SymbolicUtils v4 and crashes at runtime under Catalyst v16. - Bump `julia = "1.10"` (was `"1.9"`). MTK v11 requires Julia 1.10+. Code changes: - Replace `convert(ODESystem, rs; ...)` with `Catalyst.ode_model(rs; ...)` on Catalyst v16+ and `structural_simplify` with `mtkcompile` on MTK v11+. Both call sites are version-gated with `@static if`, so the verifier still works against the older v14/v15 + MTK v9 stack that is selected on prior SBMLToolkit releases. Local verification (Julia 1.10 LTS, SBMLToolkit fix branch from SciML/SBMLToolkit.jl#201 with the additional Catalyst v16 commit dev'd in, project resolved to Catalyst v16.1.1 + ModelingToolkit v11.24.1 + Sundials v6.1.0 + SBMLToolkit v0.1.32): - `verify_all(1:500, ...)`: 277 cases pass, 0 regressions and 0 improvements vs. the main-branch baseline (Catalyst v15 + MTK v9 + Sundials v4) — the same 277 cases pass and the same 223 fail with the same `res` outcomes. - JET tests pass (3/3, no reports). Co-Authored-By: Chris Rackauckas <[email protected]>
Summary
SymbolicUtils v4 reworked
BasicSymbolicso the type parameter must be a<: SymbolicUtils.SymVariant(SymReal/SafeReal/TreeReal); the value type (Real,Bool, …) is now stored on the value and queried viaSymbolicUtils.symtype(x). The fourcheck_args(...)::BasicSymbolic{Real}/::BasicSymbolic{Bool}methods insideget_massaction(src/reactions.jl:184-199) therefore fail to load on SymbolicUtils v4, with:This blocked precompilation of SBMLToolkit, which is why the v0.1.32 registration in JuliaRegistries/General#154236 was failing AutoMerge with
I was not able to load the package (i.e. import SBMLToolkit failed).Fix
Drop the
{Real}/{Bool}parameter from the four signatures and check the value type once at the entry point viaSymbolicUtils.symtype(x)— Bool symbolic expressions now route to the existingNaNbranch. The change is forward-compatible with SymbolicUtils v4 and stays valid against v1–v3 (where the bareBasicSymbolicabstract type still dispatches the same way), so no compat bound needs adjusting.Local verification
Julia 1.10, project resolved to SymbolicUtils v4.25.2 + ModelingToolkit v11.24.0 (i.e. the same dep set the failing AutoMerge run used):
using SBMLToolkit— precompiles and loads cleanly.Pkg.test():After this lands, retriggering Registrator on the same commit should let JuliaRegistries/General#154236 (or its successor) AutoMerge cleanly.
Test plan
import SBMLToolkitcheck.🤖 Generated with Claude Code