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

Function load_ldbc

python/graphscope/dataset/ldbc.py:27–412  ·  view source on GitHub ↗

Load ldbc dataset as a ArrowProperty Graph. Args: sess (:class:`graphscope.Session`): Load graph within the session. Default session will be used when setting to None. Defaults to None. prefix: `PathLike` object that represents a path. With standalone mod

(sess=None, prefix=None, directed=True)

Source from the content-addressed store, hash-verified

25
26
27def load_ldbc(sess=None, prefix=None, directed=True):
28 """Load ldbc dataset as a ArrowProperty Graph.
29
30 Args:
31 sess (:class:`graphscope.Session`): Load graph within the session.
32 Default session will be used when setting to None. Defaults to None.
33 prefix: `PathLike` object that represents a path.
34 With standalone mode, set prefix None will try to download from
35 source URL. Defaults to None.
36 directed (bool, optional): Determine to load a directed or undirected graph.
37 Defaults to True.
38 Returns:
39 :class:`graphscope.framework.graph.GraphDAGNode`:
40 A Graph node which graph type is ArrowProperty, evaluated in eager mode.
41
42 Examples:
43 .. code:: python
44
45 >>> # lazy mode
46 >>> import graphscope
47 >>> from graphscope.dataset import load_ldbc
48 >>> sess = graphscope.session(mode="lazy")
49 >>> g = load_ldbc(sess, "/path/to/dataset", True)
50 >>> g1 = sess.run(g)
51
52 >>> # eager mode
53 >>> import graphscope
54 >>> from graphscope.dataset import load_ldbc
55 >>> sess = graphscope.session(mode="eager")
56 >>> g = load_ldbc(sess, "/path/to/dataset", True)
57
58 """
59 if prefix is not None:
60 prefix = os.path.expandvars(prefix)
61 else:
62 fname = "ldbc_sample.tar.gz"
63 origin = f"{DATA_SITE}/ldbc_sample.tar.gz"
64 fpath = download_file(
65 fname,
66 origin=origin,
67 extract=True,
68 file_hash="1a3d3c36fbf416c2a02ca4163734192eed602649220d7ceef2735fc11173fc6c",
69 )
70 # assumed dirname is ldbc_sample after extracting from ldbc_sample.tar.gz
71 prefix = fpath[0:-7]
72
73 if sess is None:
74 sess = get_default_session()
75
76 vertices = {
77 "comment": (
78 Loader(
79 os.path.join(prefix, "comment_0_0.csv"), header_row=True, delimiter="|"
80 ),
81 ["creationDate", "locationIP", "browserUsed", "content", "length"],
82 "id",
83 ),
84 "organisation": (

Callers 7

ldbc_graphFunction · 0.90
ldbc_graph_undirectedFunction · 0.90
test_demo_distributeFunction · 0.90
test_demo_with_lazy_modeFunction · 0.90
test_helm_installationFunction · 0.90
test_download_datasetFunction · 0.85

Calls 5

download_fileFunction · 0.90
get_default_sessionFunction · 0.90
LoaderClass · 0.90
joinMethod · 0.45
load_fromMethod · 0.45

Tested by 7

ldbc_graphFunction · 0.72
ldbc_graph_undirectedFunction · 0.72
test_demo_distributeFunction · 0.72
test_demo_with_lazy_modeFunction · 0.72
test_helm_installationFunction · 0.72
test_download_datasetFunction · 0.68