From 092a0451f9cfd8fa8610b14ceaf5505e8cd1f0da Mon Sep 17 00:00:00 2001 From: Tao He Date: Wed, 14 Jun 2023 15:28:39 +0800 Subject: [PATCH] Update the pre-genereated unload_op when the op itself been deepcopied Signed-off-by: Tao He --- python/graphscope/client/session.py | 4 ++-- python/graphscope/framework/app.py | 1 + python/graphscope/framework/context.py | 1 + python/graphscope/framework/graph.py | 11 +++++++++-- python/graphscope/nx/classes/graph.py | 3 +++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/python/graphscope/client/session.py b/python/graphscope/client/session.py index 8b69c8ccfdf4..7da42cc63001 100755 --- a/python/graphscope/client/session.py +++ b/python/graphscope/client/session.py @@ -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 = {} @@ -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): diff --git a/python/graphscope/framework/app.py b/python/graphscope/framework/app.py index ea62fd13c9ad..7eb43a16bdf1 100644 --- a/python/graphscope/framework/app.py +++ b/python/graphscope/framework/app.py @@ -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 diff --git a/python/graphscope/framework/context.py b/python/graphscope/framework/context.py index 4b6f94b66383..a8b14d8e9c11 100644 --- a/python/graphscope/framework/context.py +++ b/python/graphscope/framework/context.py @@ -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 diff --git a/python/graphscope/framework/graph.py b/python/graphscope/framework/graph.py index 3b3243798608..0b4e0e173d2f 100644 --- a/python/graphscope/framework/graph.py +++ b/python/graphscope/framework/graph.py @@ -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): @@ -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. @@ -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 diff --git a/python/graphscope/nx/classes/graph.py b/python/graphscope/nx/classes/graph.py index 7b0feac84767..fed902879c75 100644 --- a/python/graphscope/nx/classes/graph.py +++ b/python/graphscope/nx/classes/graph.py @@ -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: