MCPcopy Create free account
hub / github.com/alibaba/GraphScope / wrap_results

Method wrap_results

python/graphscope/client/session.py:149–193  ·  view source on GitHub ↗
(self, response: message_pb2.RunStepResponse)

Source from the content-addressed store, hash-verified

147 return Context(context_dag_node, ret["context_key"], ret["context_schema"])
148
149 def wrap_results(self, response: message_pb2.RunStepResponse): # noqa: C901
150 rets = list()
151 for seq, op in enumerate(self._ops):
152 for op_result in response.results:
153 if op.key == op_result.key:
154 if op.output_types == types_pb2.RESULTS:
155 if op.type == types_pb2.RUN_APP:
156 rets.append(self._rebuild_context(seq, op_result))
157 elif op.type == types_pb2.REPORT_GRAPH:
158 rets.append(OutArchive(op_result.result))
159 else:
160 # for nx Graph
161 rets.append(
162 op_result.result.decode("utf-8", errors="ignore")
163 )
164 if op.output_types == types_pb2.GRAPH:
165 rets.append(self._rebuild_graph(seq, op_result))
166 if op.output_types == types_pb2.APP:
167 rets.append(None)
168 if op.output_types == types_pb2.BOUND_APP:
169 rets.append(self._rebuild_app(seq, op_result))
170 if op.output_types in (
171 types_pb2.VINEYARD_TENSOR,
172 types_pb2.VINEYARD_DATAFRAME,
173 ):
174 rets.append(
175 json.loads(
176 op_result.result.decode("utf-8", errors="ignore")
177 )["object_id"]
178 )
179 if op.output_types in (types_pb2.TENSOR, types_pb2.DATAFRAME):
180 if (
181 op.type == types_pb2.CONTEXT_TO_DATAFRAME
182 or op.type == types_pb2.GRAPH_TO_DATAFRAME
183 ):
184 rets.append(decode_dataframe(op_result.result))
185 if (
186 op.type == types_pb2.CONTEXT_TO_NUMPY
187 or op.type == types_pb2.GRAPH_TO_NUMPY
188 ):
189 rets.append(decode_numpy(op_result.result))
190 if op.output_types == types_pb2.NULL_OUTPUT:
191 rets.append(None)
192 break
193 return rets[0] if rets and self._unpack else rets
194
195 def get_dag_for_unload(self):
196 """Unload operations (graph, app, context) in dag which are not

Callers 1

run_fetchesMethod · 0.80

Calls 8

_rebuild_contextMethod · 0.95
_rebuild_graphMethod · 0.95
_rebuild_appMethod · 0.95
OutArchiveClass · 0.90
decode_dataframeFunction · 0.90
decode_numpyFunction · 0.90
appendMethod · 0.65
decodeMethod · 0.45

Tested by

no test coverage detected