MCPcopy Create free account
hub / github.com/alibaba/graph-learn / vineyard

Method vineyard

graphlearn/python/graph.py:96–187  ·  view source on GitHub ↗

Initialize a graph from vineyard. :code:`handle` is the schema information of the vineyard graph, as shown in the following example: .. code:: python { "server": "127.0.0.1:8888,127.0.0.1:8889", "client_count": 1, "vineyard_socket": "/var/r

(self, handle, nodes=None, edges=None)

Source from the content-addressed store, hash-verified

94 atexit.register(stop_sampling)
95
96 def vineyard(self, handle, nodes=None, edges=None):
97 """ Initialize a graph from vineyard.
98
99 :code:`handle` is the schema information of the vineyard graph, as shown in
100 the following example:
101
102 .. code:: python
103
104 {
105 "server": "127.0.0.1:8888,127.0.0.1:8889",
106 "client_count": 1,
107 "vineyard_socket": "/var/run/vineyard.sock",
108 "vineyard_id": 13278328736,
109 "fragments": [13278328736, ...], # fragment ids, may be None
110 "node_schema": [
111 "user:false:false:10:0:0",
112 "item:true:false:0:0:5"
113 ],
114 "edge_schema": [
115 "user:click:item:true:false:0:0:0",
116 "user:buy:item:true:true:0:0:0",
117 "item:similar:item:false:false:10:0:0"
118 ],
119 "node_attribute_types": {
120 "person": {
121 "age": "i",
122 "name": "s",
123 },
124 },
125 "edge_attribute_types": {
126 "knows": {
127 "weight": "f",
128 },
129 },
130 }
131
132 Fields in :code:`schema` are:
133
134 + the name of node type or edge type
135 + whether the graph is weighted graph
136 + whether the graph is labeled graph
137 + the number of int attributes
138 + the number of float attributes
139 + the number of string attributes
140 """
141 self._with_vineyard = True
142 if not isinstance(handle, dict):
143 handle = json.loads(base64.b64decode(handle).decode('utf-8'))
144 self._vineyard_handle = handle
145 pywrap.set_vineyard_graph_id(handle['vineyard_id'])
146 pywrap.set_vineyard_ipc_socket(handle['vineyard_socket'])
147
148 for node_info in handle['node_schema']:
149 confs = node_info.split(':')
150 if len(confs) != 6:
151 continue
152 node_type = confs[0]
153 if nodes is not None and node_type not in nodes:

Callers

nothing calls this directly

Calls 4

nodeMethod · 0.95
edgeMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected