-
Notifications
You must be signed in to change notification settings - Fork 176
pydantic BaseModel cannot be pickled w/ cloudpickle >= 1.3 #403
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
Comments
Is there any workaround for this? |
I should note that this is only an issue on Python < 3.7. So upgrading is one workaround. Or a PR to cloudpickle that makes the linked inspection code more robust. |
I'm actually running into an issue that seems related with Python 3.8.5 (cloudpickle version 1.6.0, pydantic version 1.7.3). Below is some code that reproduces the issue. import cloudpickle
import pydantic
import pickle
class Bar(pydantic.BaseModel):
a: int
pickle.loads(pickle.dumps(Bar(a=1))) # This works well
cloudpickle.loads(cloudpickle.dumps(Bar(a=1))) # This fails with the error below
|
@LaurentMazare I've tried to reproduce your issue and first couldn't under Python 3.8. After some digging I've figured out that the difference between your and my environment must be the exact pydantic "flavor" (cythonized vs not cythonized). I think what you reported here is a different issue with a different root cause. So I've opened #408 with all the details and welcome you to continue the discussion there. |
Will this be included in a release? If so, is there an ETA for that release? |
Also bypass cloudpipe/cloudpickle#403 by not storing the Record (which subclasses pydantic.BaseModel) on the transmitter, splitting it up into (data, index).
Also bypass cloudpipe/cloudpickle#403 by not storing the Record (which subclasses pydantic.BaseModel) on the transmitter, splitting it up into (data, index).
Also bypass cloudpipe/cloudpickle#403 by not storing the Record (which subclasses pydantic.BaseModel) on the transmitter, splitting it up into (data, index).
Example
Technical Background
The issue is the interaction between:
https://github.com/samuelcolvin/pydantic/blob/de0657e4a5495de9378db9fe15a17334c2b0fae5/pydantic/main.py#L865-L868
and:
cloudpickle/cloudpickle/cloudpickle.py
Line 460 in cdc704d
Refs
This was originally discussed in #393.
The text was updated successfully, but these errors were encountered: