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

Method output

python/graphscope/framework/context.py:232–276  ·  view source on GitHub ↗

Dump results to `fd`. Support dumps data to local (respect to pod) files, hdfs or oss. It first write results to a vineyard dataframe, and let vineyard do the data dumping job. `fd` must meet specific formats, with auth information if needed. As follows:

(self, fd, selector, vertex_range=None, **kwargs)

Source from the content-addressed store, hash-verified

230 return ResultDAGNode(self, op)
231
232 def output(self, fd, selector, vertex_range=None, **kwargs):
233 """Dump results to `fd`.
234 Support dumps data to local (respect to pod) files, hdfs or oss.
235 It first write results to a vineyard dataframe, and let vineyard
236 do the data dumping job.
237 `fd` must meet specific formats, with auth information if needed. As follows:
238
239 - local
240 `file:///tmp/result_path`
241 - oss
242 `oss:///bucket/object`
243 - hdfs
244 `hdfs:///tmp/result_path`
245
246 Args:
247 fd (str): Output location.
248 selector (dict): Similar to `to_dataframe`.
249 vertex_range (dict, optional): Similar to `to_dataframe`. Defaults to None.
250 kwargs (dict, optional): Storage options with respect to output storage type.
251 for example:
252 key, secret, endpoint for oss,
253 key, secret, client_kwargs for s3,
254 host, port for hdfs,
255 None for local.
256
257 Returns:
258 :class:`graphscope.framework.context.ResultDAGNode`, evaluated in eager mode.
259 """
260 protocol = fd.split("://")[0]
261 # Still use the stream to write to file,
262 # as the C++ adaptor in Vineyard requires arrow >= 4.0.0
263 if protocol in ("file", "hdfs", "hive", "oss", "s3"):
264 df = self.to_vineyard_dataframe(selector, vertex_range)
265 op = dag_utils.to_data_sink(df, fd, **kwargs)
266 else:
267 check_argument(
268 isinstance(selector, Mapping), "selector of to_dataframe must be a dict"
269 )
270 for _, value in selector.items():
271 self._check_selector(value)
272 _ensure_consistent_label(self.context_type, selector)
273 selector = json.dumps(selector)
274 vertex_range = utils.transform_vertex_range(vertex_range)
275 op = dag_utils.output(self, fd, selector, vertex_range, **kwargs)
276 return ResultDAGNode(self, op)
277
278 def __del__(self):
279 try:

Callers

nothing calls this directly

Calls 8

to_vineyard_dataframeMethod · 0.95
_check_selectorMethod · 0.95
check_argumentFunction · 0.90
_ensure_consistent_labelFunction · 0.85
ResultDAGNodeClass · 0.85
splitMethod · 0.80
itemsMethod · 0.80
outputMethod · 0.45

Tested by

no test coverage detected