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

1.3.0 cloudpickle.load hits AttributeError: module 'types' has no attribute 'ClassType' #349

Closed
mzhang-code opened this issue Mar 10, 2020 · 5 comments

Comments

@mzhang-code
Copy link

After upgrading to 1.3.0 from 1.2.2, our load() code starts having this issue.

 File "/usr/local/lib/python3.6/site-packages/cloudpickle/cloudpickle.py", line 415, in _builtin_type
     return getattr(types, name)
 AttributeError: module 'types' has no attribute 'ClassType'

Also found this post described the same issue we got. mlflow/mlflow#2429

I suspect it is caused by #337 "Fix a side effect that would redefine types.ClassTypes as type when importing cloudpickle", which removed types.ClassType = type

@ogrisel
Copy link
Contributor

ogrisel commented Apr 27, 2020

Coming back to this issue. As per cloudpickle's README and and as I replied in mlflow/mlflow#2429 (comment) , cloudpickle does not support loading objects from prior versions as it's only meant to transient object flowing between the nodes of a cluster.

That being said we could temporarily do an effort for backward compat this time with something like:

if not hasattr(types, "ClassType"):
    types.ClassType = type

but this is weird and I would rather not have this on the long term.

@pierreglaser
Copy link
Member

That being said we could temporarily do an effort for backward compat this time with something like:

I'm afraid the proposed workaround will end up recreating the problem reported in #337.

@pierreglaser
Copy link
Member

What might work though is special-casing type in

def _builtin_type(name):
return getattr(types, name)

@ogrisel
Copy link
Contributor

ogrisel commented Apr 27, 2020

Yes, this is what I was coming to by reading the reports. Let's add a small compat fix there.

@ogrisel
Copy link
Contributor

ogrisel commented Apr 28, 2020

Compat fix implemented in #359.

@ogrisel ogrisel closed this as completed Apr 28, 2020
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