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.
Summary
My team and I have been developing a web application (based on plotly dash) that uses openmdao quite heavily in the backend. In order to pass objects between callbacks we need to serialize them and then de-serialize them. We're currently looking to upgrade from openmdao 3.17 to 3.30 and these are two fixes to issues we encountered related to serialized openmdao objects and passing them between processes. I know this probably isn't too common of a use case, but I'd appreciate if these changes could be accepted.
1. weakref serialization
Serialization of a weakref breaks the reference. After a weakref is broken, it becomes a function that returns None. This is shown in the following code
This case is not accounted for in the System._setup solvers function logic. The RuntimeError error will always be raised as
self._system()
is None, notself._system
.This was corrected as follows
2. self.matrix_free is _UNDEFINED
The
is
function can be a little finicky when working with multiprocessing and passing an object between processes. We found instances where the object would be created in one process, then passed to another andself.matrix_free is _UNDEFINED
would returnFalse
butself.matrix_free == _UNDEFINED
would returnTrue
. This is because the_UNDEFINED
class it's referencing is a class from another process (thus makingis
False
) but they are equivalent (thus making==
True
). This therefor broke the configure stack for us.I've made the change in
ExplicitComponent
andImplicitComponent
_configure
to fix this.Related Issues
Backwards incompatibilities
None
New Dependencies
None