Skip to content

Commit

Permalink
Update the pre-genereated unload_op when the op itself been deepcopied (
Browse files Browse the repository at this point in the history
#2888)

The issue was first introduced in #2843.

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
  • Loading branch information
sighingnow committed Jun 14, 2023
1 parent 32089f2 commit fbf40f6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions python/graphscope/client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def __init__(
# "vineyard_socket": "...",
# "vineyard_rpc_endpoint": "..."
# }
self._engine_config: {} = None
self._engine_config: dict = None

# interactive instance related graph map
self._interactive_instance_dict = {}
Expand Down Expand Up @@ -713,7 +713,7 @@ def session_id(self) -> str:
return self._session_id

@property
def dag(self):
def dag(self) -> Dag:
return self._dag

def _log_session_info(self):
Expand Down
1 change: 1 addition & 0 deletions python/graphscope/framework/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def __init__(self, app_node, key):
# copy and set op evaluated
self._app_node.op = deepcopy(self._app_node.op)
self._app_node.evaluated = True
self._app_node._unload_op = unload_app(self._app_node)
self._session.dag.add_op(self._app_node.op)
self._saved_signature = self.signature

Expand Down
1 change: 1 addition & 0 deletions python/graphscope/framework/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ def __init__(self, context_node, key, result_schema):
# copy and set op evaluated
self._context_node.op = deepcopy(self._context_node.op)
self._context_node.evaluated = True
self._context_node._unload_op = dag_utils.unload_context(self._context_node)
self._saved_signature = self.signature

@property
Expand Down
11 changes: 9 additions & 2 deletions python/graphscope/framework/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,12 @@ def __init__(
self._resolve_op(incoming_data)
self._session.dag.add_op(self._op)

# statically create the unload op
self._unload_op = dag_utils.unload_graph(self)
# statically create the unload op, as the op may change, the
# unload op should be refreshed as well.
if self._op is None:
self._unload_op = None
else:
self._unload_op = dag_utils.unload_graph(self)

@property
def v_labels(self):
Expand Down Expand Up @@ -377,6 +381,8 @@ def _resolve_op(self, incoming_data):
self._op = self._from_nx_graph(incoming_data)
else:
raise RuntimeError("Not supported incoming data.")
# update the unload op
self._unload_op = dag_utils.unload_graph(self)

def to_numpy(self, selector, vertex_range=None):
"""Select some elements of the graph and output to numpy.
Expand Down Expand Up @@ -806,6 +812,7 @@ def __init__(
# copy and set op evaluated
self._graph_node.op = deepcopy(self._graph_node.op)
self._graph_node.evaluated = True
self._graph_node._unload_op = dag_utils.unload_graph(self._graph_node)
self._session.dag.add_op(self._graph_node.op)

self._key = None
Expand Down
3 changes: 3 additions & 0 deletions python/graphscope/nx/classes/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ def __init__(self, incoming_graph_data=None, default_label=None, **attr):
self._is_client_view = False

# statically create the unload op
#
# networkx operations update the op, but keep the key as same, thus
# the unload op don't need to be refreshed.
if self.op is None:
self._unload_op = None
else:
Expand Down

0 comments on commit fbf40f6

Please sign in to comment.