Closed
Description
System information
- Ray installed from (source or binary): pip
- Ray version: 0.2.2
- Python version: 3.6.2
Describe the problem
Ray fails to serialize self-reference objects (for example, Graph objects in networkx).
I think it is because ray always tries to use pyarrow first and does not catch pyarrow.lib.ArrowNotImplementedError
, see
Lines 285 to 289 in e0360eb
After catching pyarrow.lib.ArrowNotImplementedError
, we should not use use_dict=True
as a workaround, because it will cause endless loop. A correct approach may be:
except (pyarrow.SerializationCallbackError, pyarrow.lib.ArrowNotImplementedError) as e:
try:
if isinstance(e, pyarrow.lib.ArrowNotImplementedError):
e.example_object = value
raise e # redirect to use cloudpickle
Source code / logs
class Graph:
def __init__(self):
self.g = self
G = Graph()
ray.put(G) # --> pyarrow.lib.ArrowNotImplementedError: This object exceeds the maximum recursion depth. It may contain itself recursively.
# another example
import networkx as nx
G = nx.Graph()
G.add_edges_from([(1, 2), (1, 3)])
G.add_node(1)
G.add_edge(1, 2)
G.add_node("spam") # adds node "spam"
G.add_nodes_from("spam") # adds 4 nodes: 's', 'p', 'a', 'm'
G.add_edge(3, 'm')
ray.put(G) # --> pyarrow.lib.ArrowNotImplementedError: This object exceeds the maximum recursion depth. It may contain itself recursively.
Metadata
Metadata
Assignees
Labels
No labels