crocoddyl
crocoddyl copied to clipboard
Pickling issues
Hello, can crocoddyl be pickled yet? I rember that @cmastalli said that there were issues with eigen for that, but maybe I'm mistaken and that is not the case anymore . I have a runtime error related to this using multiprocessing, it would be great if it could be fixed/was supported.
You cannot pickle entire Crocoddyl data. However you could pickle some data, e.g. Pinocchio data, NumPy, etc.
Unfortunately I don't have time now for adding this feature.
I would like to take this thread to discuss which classes / structures should be pickleable. I was thinking in this set of classes / structures:
- All data structures
- All model classes
- All solver classes
-
Python list
to/fromstd::vector
-
Python Dict
to/fromstd::map
What do you think? @proyan @gfadini @jcarpent @wxmerkt
This also requires a lot of work. I notice that there is a light alternative that will be faster to deploy but we need to inject a __getinitargs__
method, see details:
https://www.boost.org/doc/libs/1_58_0/libs/python/doc/v2/pickle.html (picke4)
is this would make sense for you guys?
@cmastalli You should take inspiration from https://github.com/stack-of-tasks/pinocchio which is using the serialization for the pickling of large data structure, which is in the end much more efficient and allows to export in C++ too.
The solver should not be pickable at first glance. Only data and model in the first place. By the way, for Python list, you should use the code from Pinocchio too.
@cmastalli You should take inspiration from https://github.com/stack-of-tasks/pinocchio which is using the serialization for the pickling of large data structure, which is in the end much more efficient and allows to export in C++ too.
I reviewed again this code, and I have two questions.
- It seems to me that
getinitargs
assumes that there are no arguments for the object construction. So if I understand correctly, this function can be removed, right? What happens is my class needs some arguments? - Does this code assume that the state of the instance is always a public member?
Ideally I would like to reuse this code for pickling action models and datas, however, it seems to me that it is not possible. I mean, I need to set some private states using set_XXX
functions and pass some arguments to construct the object.
For me, the serialization mechanism is a bit obscure.