-
Notifications
You must be signed in to change notification settings - Fork 167
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
Cloudpickle cannot pickle cythonized methods #259
Comments
We do have our own way of pickling methods, which fails in this case. Is |
I guess we should assume so. In this case the module can be imported on the client node and the error is raised at pickling time so this is a bug. |
Thank you for the replies ogrisel and pierreglaser ! I eventually got my initial problem sorted by modifying getstate/setstate, this was a pickling issue on my side. If pickling cython methods is not a bug then I guess the issue can be closed. |
No if it works with regular python pickle.dumps and the module is expected to be installed on all the nodes of the cluster, then it should work with cloudpickle, so I believe this is a bug. I did not look into the details yet though. |
If this is fixed, it would be great to write a non-regression test and a changelog entry. |
I just checked, it is not fixed. But I'm working on it as this issue is also appearing in #273. |
FYI, this was primarily a |
Should be included in Cython 0.29.24 (once released) |
I'm using Dask to parallelize computing. And my code is compiled with cython.
When computing, Dask actually asks cloudpickle to dump the compute method, but this operation fails.
The problem is that it looks like cloudpickle cannot dump methods of a class if this class has been compiled with cython. But such methods can be dumped using pickle.
How to reproduce:
Here is the code of the class below. I'd like to pickle the method
my_method
from an object of this class:The following code works properly when importing from the python module:
But this fails if the module is cythonized.
If the module is cythonized and
MyClass
is imported from there, call tocloudpickle.dumps(my_obj.my_method)
generates the following error:Here is the simple setup.py file I'm using to generate the cythonized module:
then:
python setup.py build_ext --inplace
.Note that using standard pickle works on both python & cythonized code, ie:
import pickle; pickle.dumps(my_obj.my_func)
works properlyDid I miss something?
I tried adding
__getstate__
/__setstate__
that returnself.__dict__
but this does not solve the problem.Does some of you have any clue about this? Thanks for the help :)
The text was updated successfully, but these errors were encountered: