Repository navigation
Restore ProblemTypeCtx as the discretization metadata key - #99
Merged
ChrisRackauckas merged 2 commits intoJul 29, 2026
Merged
ChrisRackauckas merged 2 commits into
ChrisRackauckas merged 2 commits into
Conversation
Substituting a PDEBase-owned metadata key for `ProblemTypeCtx` silently broke the MethodOfLines solution interface. `ProblemTypeCtx` is not a private helper that can be reproduced locally: ModelingToolkitBase reads it to populate `prob.problem_type`, and SciMLBase's `wrap_sol` dispatches on that value to build a `PDETimeSeriesSolution`. With a different key the metadata never reaches `problem_type`, `wrap_sol` falls through to the identity method, and a raw `ODESolution` comes back with no error at discretize or solve time, so `sol[u(t,x)]` fails. Import it from ModelingToolkitBase, the owner, rather than through the ModelingToolkit re-export. That satisfies the owner check; the remaining publicness check needs the upstream `public` declaration in SciML/ModelingToolkit.jl#4842, so keep one narrow QA ignore until that ships. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m
`ProblemTypeCtx` is public as of ModelingToolkitBase 1.58.0 (SciML/ModelingToolkit.jl#4842), so PDEBase can import it from its owner with no exception. QA is now fully strict. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m
Member
Author
|
Pushed c3d18b3. ModelingToolkitBase 1.58.0 is registered (JuliaRegistries/General#162639), so the temporary QA ignore is gone — This completes the intent of #98 without the workaround: Verified against the registered 1.58.0 (not a dev checkout) on Julia 1.12.6:
Two things remain outside this PR:
Ignore until reviewed by @ChrisRackauckas. |
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.
Follow-up to #98, which merged before this fix landed on its branch.
Problem
#98 replaced
ModelingToolkitBase.ProblemTypeCtxwith a PDEBase-localPDEBaseMetadataCtxinsrc/discretization_state.jl. That was done to clear a QA ignore —ProblemTypeCtxis a non-public ModelingToolkitBase name, and master's oldtest/qa/qa.jllisted it under bothall_explicit_imports_via_ownersandall_explicit_imports_are_public.ProblemTypeCtxis not a private helper that can be substituted. It is a documented protocol key with behavior attached in two packages:ModelingToolkitBase/src/systems/system.jl:1210— "Metadata key for systems containing theproblem_typeto be passed to the problem constructor…ODEProblem(sys, ...).problem_typewill beCustomType()instead ofStandardODEProblem", read atproblems/odeproblem.jl:133andproblems/nonlinearproblem.jl:127.SciMLBase/src/solutions/basic_solutions.jl:195—wrap_sol(sol)readsproblem_type(prob)and, persolutions/pde_solutions.jl:160, routes anAbstractDiscretizationMetadatatoPDETimeSeriesSolution/PDENoTimeSolution. Anything else falls through towrap_sol(sol, _) = sol.PDEBase writes that key so SciMLBase wraps the solve result. With a different key the metadata never reaches
problem_type, and a rawODESolutioncomes back — with no error at discretize or solve time.Measured on Julia 1.12.6, same heat-equation script, only PDEBase swapped:
prob.problem_typeStandardODEProblemMOLMetadata{Val{true}(),…}typeof(sol)ODESolutionPDETimeSeriesSolutionsol isa AbstractPDESolutionfalsetruesol[u(t,x)]ArgumentError: Symbol u(t, x) is not present in the system(3,11)MethodOfLines also reads the old key directly at
MOL_discretization.jl:117andstaggered_discretize.jl:10/:17.Fix
Import
ProblemTypeCtxfrom ModelingToolkitBase — the owner — instead of through the ModelingToolkit re-export. That satisfies the owner check by itself. The publicness check needs the upstream declaration in SciML/ModelingToolkit.jl#4842, sotest/qa/qa.jlkeeps exactly one narrow ignore pointing at it; everything else stays strict. Once #4842 releases, that ignore can be deleted.Validation
GROUP=Core Pkg.test()on 1.12.6 against this branch: 12 + 18 + 46 pass.Sol_Interface(12/12) andBurgerspass against this branch with MOL compat locally widened.Note on downstream
Downstream is red on master independently of this PR: master is now
0.2.0and MethodOfLines pinsPDEBase = "0.1.29", so every downstream job dies at resolution. That needs a MethodOfLines PR — compat"0.1.29, 0.2", plususing DomainSets: Intervalandimport SciMLBase.symbolic_discretize, since PDEBase no longer re-exports either (a hard load error on the Julia LTS, only a warning on 1.11+). Tracked separately from this fix.Ignore until reviewed by @ChrisRackauckas.
🤖 Generated with Claude Code
https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m