-
-
Notifications
You must be signed in to change notification settings - Fork 233
Allow evaluation module to be specified when building an ODEFunction #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think this should work. I'll just want @c42f's opinion on the safety. |
Perhaps there's two separate things desired here?
In principle these might be separate modules, I suppose, so SciML/RuntimeGeneratedFunctions.jl#20 might only be half the story? |
Oh I just read this. Yes, good point. |
Updated this to work with SciML/RuntimeGeneratedFunctions.jl#20. |
Can this get updated for SciML/RuntimeGeneratedFunctions.jl#22 and handle all of the system types? |
This adds the ability to manually specify which module's cache to use when an RGF is built as part of an ODEFunction. Basically, together with
eval_expression
you can now specifyeval_module=@__MODULE__
(the default, which simply uses ModelingToolkit's RGF cache).I've added an example test case, which consists of building an ODEFunction as part of a precompiled user module.
In this case, "f_bad" throws a
KeyError
because it does not useeval_module
, so it's tagged in the ModelingToolkit RGF cache which is not kept after precompilation of the user module is done.On the other hand, "f_good" works because it supplies the user module to
eval_module
, allowing ModelingToolkit to build the RGF within the user module's cache.NOTE: there's a few other uses of @RuntimeGeneratedFunctions that probably could do with a similar fix to this, or some better solution. I am not sure how best to tackle this other than the current way, so I would appreciate any comments, but I'll leave that out of scope for this PR as it at least fixes #678 for me.