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

Class GLTorchGraph

python/graphscope/learning/gl_torch_graph.py:20–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19
20class GLTorchGraph(object):
21 def __init__(self, server_list):
22 assert len(server_list) == 4
23 self._master_addr, self._server_client_master_port = server_list[0].split(":")
24 self._train_master_addr, self._train_loader_master_port = server_list[1].split(
25 ":"
26 )
27 self._val_master_addr, self._val_loader_master_port = server_list[2].split(":")
28 self._test_master_addr, self._test_loader_master_port = server_list[3].split(
29 ":"
30 )
31 assert (
32 self._master_addr
33 == self._train_master_addr
34 == self._val_master_addr
35 == self._test_master_addr
36 )
37
38 @property
39 def master_addr(self):
40 return self._master_addr
41
42 @property
43 def server_client_master_port(self):
44 return self._server_client_master_port
45
46 @property
47 def train_loader_master_port(self):
48 return self._train_loader_master_port
49
50 @property
51 def val_loader_master_port(self):
52 return self._val_loader_master_port
53
54 @property
55 def test_loader_master_port(self):
56 return self._test_loader_master_port
57
58 @staticmethod
59 def check_edge(schema, edge):
60 if not isinstance(edge, tuple) or len(edge) != 3:
61 raise ValueError("Each edge should be a tuple of length 3")
62 for vertex_label in [edge[0], edge[2]]:
63 if vertex_label not in schema.vertex_labels:
64 raise ValueError(f"Invalid edge label: {vertex_label}")
65 if edge[1] not in schema.edge_labels:
66 raise ValueError(f"Invalid edge label: {edge[1]}")
67
68 @staticmethod
69 def check_edges(schema, edges):
70 for edge in edges:
71 GLTorchGraph.check_edge(schema, edge)
72 if edge in edges[edges.index(edge) + 1 :]:
73 raise ValueError(f"Duplicated edge: {edge}")
74
75 @staticmethod
76 def check_features(feature_names, properties):
77 data_type = None

Callers 2

graphlearn_torchMethod · 0.90
client.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected