Skip to content

Commit

Permalink
Serialize of ProxyObject to pickle fixed attributes (#1137)
Browse files Browse the repository at this point in the history
The proxied's `name` attribute might contain types not support by msgpack. We now pickle the fixed attributes when serializing. 

Closes #1136

Authors:
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)
  - Peter Andreas Entschev (https://github.com/pentschev)

URL: #1137
  • Loading branch information
madsbk authored Mar 6, 2023
1 parent 3fadc30 commit 64a92a1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dask_cuda/proxy_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,10 @@ def obj_pxy_dask_serialize(obj: ProxyObject):
header, frames = pxy.serialize(serializers=("dask", "pickle"))
obj._pxy_set(pxy)

return {"proxied-header": header, "obj-pxy-detail": pxy.get_init_args()}, frames
return {
"proxied-header": header,
"obj-pxy-detail": pickle.dumps(pxy.get_init_args()),
}, frames


@distributed.protocol.cuda.cuda_serialize.register(ProxyObject)
Expand All @@ -860,7 +863,10 @@ def obj_pxy_cuda_serialize(obj: ProxyObject):
# the worker's data store.
header, frames = pxy.serialize(serializers=("cuda",))

return {"proxied-header": header, "obj-pxy-detail": pxy.get_init_args()}, frames
return {
"proxied-header": header,
"obj-pxy-detail": pickle.dumps(pxy.get_init_args()),
}, frames


@distributed.protocol.dask_deserialize.register(ProxyObject)
Expand All @@ -872,7 +878,7 @@ def obj_pxy_dask_deserialize(header, frames):
deserialized using the same serializers that were used when the object was
serialized.
"""
args = header["obj-pxy-detail"]
args = pickle.loads(header["obj-pxy-detail"])
if args["subclass"] is None:
subclass = ProxyObject
else:
Expand Down

0 comments on commit 64a92a1

Please sign in to comment.