Skip to content
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

Pickling issues #704

Open
gfadini opened this issue Mar 4, 2020 · 5 comments
Open

Pickling issues #704

gfadini opened this issue Mar 4, 2020 · 5 comments

Comments

@gfadini
Copy link
Contributor

gfadini commented Mar 4, 2020

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.

@cmastalli
Copy link
Member

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.

@cmastalli
Copy link
Member

I would like to take this thread to discuss which classes / structures should be pickleable. I was thinking in this set of classes / structures:

  1. All data structures
  2. All model classes
  3. All solver classes
  4. Python list to/from std::vector
  5. Python Dict to/from std::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?

@jcarpent
Copy link
Member

jcarpent commented Apr 2, 2020

@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.

@jcarpent
Copy link
Member

jcarpent commented Apr 2, 2020

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
Copy link
Member

cmastalli commented Jul 23, 2020

@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.

  1. 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?
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants