MCPcopy
hub / github.com/ray-project/ray / pickle_dumps

Function pickle_dumps

python/ray/_common/serialization.py:21–34  ·  view source on GitHub ↗

Wrap cloudpickle.dumps to provide better error message when the object is not serializable.

(obj: Any, error_msg: str)

Source from the content-addressed store, hash-verified

19
20
21def pickle_dumps(obj: Any, error_msg: str):
22 """Wrap cloudpickle.dumps to provide better error message
23 when the object is not serializable.
24 """
25 try:
26 return pickle.dumps(obj)
27 except (TypeError, ray.exceptions.OufOfBandObjectRefSerializationException) as e:
28 sio = io.StringIO()
29 inspect_serializability(obj, print_file=sio)
30 msg = f"{error_msg}:\n{sio.getvalue()}"
31 if isinstance(e, TypeError):
32 raise TypeError(msg) from e
33 else:
34 raise ray.exceptions.OufOfBandObjectRefSerializationException(msg)

Callers 6

_remoteMethod · 0.90
decoratorFunction · 0.90
createMethod · 0.90
from_objectsMethod · 0.90
export_actor_classMethod · 0.90

Calls 1

inspect_serializabilityFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…