You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pydantic BaseModel cannot be pickled w/ cloudpickle >= 1.3 #403
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).
The example given at the top of this issue works fine however, adding a field to the model makes cloudpickle break whereas the standard pickle module works fine.
Below is some code that reproduces the issue.
importcloudpickleimportpydanticimportpickleclassBar(pydantic.BaseModel):
a: intpickle.loads(pickle.dumps(Bar(a=1))) # This works wellcloudpickle.loads(cloudpickle.dumps(Bar(a=1))) # This fails with the error below
PicklingError: Can't pickle <cyfunction int_validator at 0x7ff32fa23ad0>: attribute lookup lambda12 on pydantic.validators failed
@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.
Activity
erccarls commentedon Dec 17, 2020
Is there any workaround for this?
marco-neumann-by commentedon Dec 17, 2020
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.
LaurentMazare commentedon Dec 23, 2020
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).
The example given at the top of this issue works fine however, adding a field to the model makes cloudpickle break whereas the standard pickle module works fine.
Below is some code that reproduces the issue.
marco-neumann-by commentedon Jan 21, 2021
@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.
jondequinor commentedon Mar 25, 2021
Will this be included in a release? If so, is there an ETA for that release?
Fix styling and typing
Fix styling and typing
Fix styling and typing