load the node partition ids from the disk Parameters: ---------- partitions_dir : string directory path where metis/random partitions are located graph_schema : json object which is created by reading the metadata.json file for the original graph Returns
(partitions_dir, graph_schema)
| 180 | |
| 181 | |
| 182 | def get_node_partids(partitions_dir, graph_schema): |
| 183 | """load the node partition ids from the disk |
| 184 | |
| 185 | Parameters: |
| 186 | ---------- |
| 187 | partitions_dir : string |
| 188 | directory path where metis/random partitions are located |
| 189 | graph_schema : json object |
| 190 | which is created by reading the metadata.json file for the |
| 191 | original graph |
| 192 | |
| 193 | Returns: |
| 194 | -------- |
| 195 | dictionary : |
| 196 | where keys are node-types and value is a list of partition-ids for all the |
| 197 | nodes of that particular node-type. |
| 198 | """ |
| 199 | assert os.path.isdir( |
| 200 | partitions_dir |
| 201 | ), f"Please provide a valid directory to read nodes to partition-id mappings." |
| 202 | _, gid_dict = get_idranges( |
| 203 | graph_schema[constants.STR_NODE_TYPE], |
| 204 | dict( |
| 205 | zip( |
| 206 | graph_schema[constants.STR_NODE_TYPE], |
| 207 | graph_schema[constants.STR_NODE_TYPE_COUNTS], |
| 208 | ) |
| 209 | ), |
| 210 | ) |
| 211 | node_partids = {} |
| 212 | for ntype_id, ntype in enumerate(graph_schema[constants.STR_NODE_TYPE]): |
| 213 | node_partids[ntype] = read_file( |
| 214 | os.path.join(partitions_dir, f"{ntype}.txt"), constants.STR_CSV |
| 215 | ) |
| 216 | assert ( |
| 217 | len(node_partids[ntype]) |
| 218 | == graph_schema[constants.STR_NODE_TYPE_COUNTS][ntype_id] |
| 219 | ), f"Node count for {ntype} = {len(node_partids[ntype])} in the partitions_dir while it should be {graph_schema[constants.STR_NTYPE_COUNTS][ntype_id]} (from graph schema)." |
| 220 | |
| 221 | return node_partids |
| 222 | |
| 223 | |
| 224 | def verify_node_partitionids( |
no test coverage detected