Skip to content

Add pickle support to FMUModel classes via __reduce__/__setstate__#409

Open
jschueller wants to merge 2 commits into
modelon-community:masterfrom
jschueller:issue363
Open

Add pickle support to FMUModel classes via __reduce__/__setstate__#409
jschueller wants to merge 2 commits into
modelon-community:masterfrom
jschueller:issue363

Conversation

@jschueller
Copy link
Copy Markdown
Contributor

Fixes serialization of FMU model objects (FMUModelCS1/2, FMUModelME1/2/3) for use with pickle, multiprocessing, and joblib. C-level extension type attributes (_context, _fmu, callBackFunctions, callbacks) are not directly picklable, so reduce reconstructs the model from scratch by storing the FMU path and log settings, and setstate restores the user-visible cache dict.

Closes #363

Fixes serialization of FMU model objects (FMUModelCS1/2, FMUModelME1/2/3)
for use with pickle, multiprocessing, and joblib. C-level extension type
attributes (_context, _fmu, callBackFunctions, callbacks) are not directly
picklable, so __reduce__ reconstructs the model from scratch by storing
the FMU path and log settings, and __setstate__ restores the user-visible
cache dict.

Closes modelon-community#363
@jschueller jschueller marked this pull request as draft May 21, 2026 05:25
@jschueller jschueller marked this pull request as ready for review May 21, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: self._context,self._fmu,self.callBackFunctions,self.callbacks cannot be converted to a Python object for pickling

1 participant