MCPcopy
hub / github.com/dmlc/dgl / verify_metadata_counts

Function verify_metadata_counts

tools/verification_utils.py:143–179  ·  view source on GitHub ↗

Verify the partitioned graph objects with the metadata Parameters: ----------- part_schema : json object which is created by reading the metadata.json file for the partitioned graph part_g : DGL graph object of a graph partition graph_schema : json object

(part_schema, part_g, graph_schema, g, partid)

Source from the content-addressed store, hash-verified

141
142
143def verify_metadata_counts(part_schema, part_g, graph_schema, g, partid):
144 """Verify the partitioned graph objects with the metadata
145
146 Parameters:
147 -----------
148 part_schema : json object
149 which is created by reading the metadata.json file for the
150 partitioned graph
151 part_g : DGL graph object
152 of a graph partition
153 graph_schema : json object
154 which is created by reading the metadata.json file for the
155 original graph
156 g : DGL Graph object
157 created by reading the original graph from the disk.
158 partid : integer
159 specifying the partition id of the graph object, part_g
160 """
161 for ntype in part_schema[constants.STR_NTYPES]:
162 ntype_data = part_schema[constants.STR_NODE_MAP][ntype]
163 meta_ntype_count = ntype_data[partid][1] - ntype_data[partid][0]
164 inner_node_mask = _get_inner_node_mask(part_g, g.get_ntype_id(ntype))
165 graph_ntype_count = len(part_g.ndata[dgl.NID][inner_node_mask])
166 assert (
167 meta_ntype_count == graph_ntype_count
168 ), f"Metadata ntypecount = {meta_ntype_count} and graph_ntype_count = {graph_ntype_count}"
169
170 for etype in part_schema[constants.STR_ETYPES]:
171 etype_data = part_schema[constants.STR_EDGE_MAP][etype]
172 meta_etype_count = etype_data[partid][1] - etype_data[partid][0]
173 mask = _get_inner_edge_mask(
174 part_g, g.get_etype_id(_etype_str_to_tuple(etype))
175 )
176 graph_etype_count = len(part_g.edata[dgl.EID][mask])
177 assert (
178 meta_etype_count == graph_etype_count
179 ), f"Metadata etypecount = {meta_etype_count} does not match part graph etypecount = {graph_etype_count}"
180
181
182def get_node_partids(partitions_dir, graph_schema):

Callers 1

_validate_resultsFunction · 0.90

Calls 5

_get_inner_node_maskFunction · 0.90
_get_inner_edge_maskFunction · 0.90
_etype_str_to_tupleFunction · 0.90
get_ntype_idMethod · 0.45
get_etype_idMethod · 0.45

Tested by

no test coverage detected