()
| 21 | |
| 22 | @unittest.skipIf(True, reason="mpi is not available in CI test framework.") |
| 23 | def test_parmetis_preprocessing(): |
| 24 | with tempfile.TemporaryDirectory() as root_dir: |
| 25 | num_chunks = 2 |
| 26 | g = create_chunked_dataset(root_dir, num_chunks) |
| 27 | |
| 28 | # Trigger ParMETIS pre-processing here. |
| 29 | input_dir = os.path.join(root_dir, "chunked-data") |
| 30 | results_dir = os.path.join(root_dir, "parmetis-data") |
| 31 | os.system( |
| 32 | f"mpirun -np {num_chunks} python3 tools/distpartitioning/parmetis_preprocess.py " |
| 33 | f"--schema {metadata.json} " |
| 34 | f"--input_dir {input_dir} " |
| 35 | f"--output_dir {results_dir} " |
| 36 | f"--num_parts {num_chunks}" |
| 37 | ) |
| 38 | |
| 39 | # Now add all the tests and check whether the test has passed or failed. |
| 40 | # Read parmetis_nfiles and ensure all files are present. |
| 41 | parmetis_data_dir = os.path.join(root_dir, "parmetis-data") |
| 42 | assert os.path.isdir(parmetis_data_dir) |
| 43 | parmetis_nodes_file = os.path.join( |
| 44 | parmetis_data_dir, "parmetis_nfiles.txt" |
| 45 | ) |
| 46 | assert os.path.isfile(parmetis_nodes_file) |
| 47 | |
| 48 | # `parmetis_nfiles.txt` should have each line in the following format. |
| 49 | # <filename> <global_id_start> <global_id_end> |
| 50 | with open(parmetis_nodes_file, "r") as nodes_metafile: |
| 51 | lines = nodes_metafile.readlines() |
| 52 | total_node_count = 0 |
| 53 | for line in lines: |
| 54 | tokens = line.split(" ") |
| 55 | assert len(tokens) == 3 |
| 56 | assert os.path.isfile(tokens[0]) |
| 57 | assert int(tokens[1]) == total_node_count |
| 58 | |
| 59 | # check contents of each of the nodes files here |
| 60 | with open(tokens[0], "r") as nodes_file: |
| 61 | node_lines = nodes_file.readlines() |
| 62 | for line in node_lines: |
| 63 | val = line.split(" ") |
| 64 | # <ntype_id> <weight_list> <mask_list> <type_node_id> |
| 65 | assert len(val) == 8 |
| 66 | node_count = len(node_lines) |
| 67 | total_node_count += node_count |
| 68 | assert int(tokens[2]) == total_node_count |
| 69 | |
| 70 | # Meta_data object. |
| 71 | output_dir = os.path.join(root_dir, "chunked-data") |
| 72 | json_file = os.path.join(output_dir, "metadata.json") |
| 73 | assert os.path.isfile(json_file) |
| 74 | with open(json_file, "rb") as f: |
| 75 | meta_data = json.load(f) |
| 76 | |
| 77 | # Count the total no. of nodes. |
| 78 | true_node_count = 0 |
| 79 | num_nodes_per_chunk = meta_data["num_nodes_per_chunk"] |
| 80 | for i in range(len(num_nodes_per_chunk)): |
nothing calls this directly
no test coverage detected