-
Notifications
You must be signed in to change notification settings - Fork 171
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 breaks isinstance #195
Comments
Was about to post essentially the same issue:
|
I believe this is only an issue for classes defined in # example_module.py
class Foo(object):
pass # example_main.py
import cloudpickle
from example_module import Foo
assert cloudpickle.loads(cloudpickle.dumps(Foo())).__class__ is Foo
print("Finished successfully!")
This works normally because pickle's default strategy for serializing classes (which cloudpickle inherits in most cases) is to serialize classes by just storing a module name and attribute, and to deserialize by importing the corresponding module and getting the attribute. This has the nice property that serializing and deserializing a type gives back the same type object, which is why The reason this doesn't work for classes defined in
|
One way we could potentially try to solve this would be to change the deserialization algorithm for Another option might be to try to trigger a warning if an |
The problem is that most of the time you actually want to redefine the class: cloudpickle is typically used to add support for cluster computing (PySpark / dask / ray) to interactive programming environment (e.g. a Python shell, script or Jupyter Notebook): If the user iteratively refines the implementation of a function or a class, you actually want the new code to be taken into account in subsequent calls that involve new instances of the class whose code has been changed. I don't see how this is compatible with what is asked by OP. |
@bluenote10 @bluescarni @ssanderson I implemented a fix for this in #246. Feel free to give it a try. |
cloudpickle 1.1.0 is out with a fix for this problem. |
Follow up to dask/distributed#2228
Using
cloudpickle==0.5.5
, Python 2.7.12, Ubuntu 16.04.The text was updated successfully, but these errors were encountered: