import multiprocessing import subprocess def process_file(file_index): source_file = f"mixed_32k_redstone_part_{file_index}_streaming_4096.jsonl" batch_size = 16 command = [ "python", "preprocess_longtext_streaming_step2.py", "--source_file", source_file, "--batch_size", str(batch_size) ] subprocess.run(command) def process_in_parallel(num_files=20, num_processes=20): with multiprocessing.Pool(processes=num_processes) as pool: pool.map(process_file, range(1, num_files + 1)) if __name__ == "__main__": process_in_parallel(num_files=19, num_processes=19)