import pdb import subprocess import re # Output file output_file = "pass_rate_output.txt" # Clearing the output file before appending new content with open(output_file, "w") as file: file.write("") # List of input paths input_path_lists = [ "test/zero_shot/wild_test/generation/lean4_random_15k_all/2/1/", ] def get_output(input_string, k): pattern = r"gpt_result/(\w+)/(\w+)" match = re.search(pattern, input_string) if match: part1 = match.group(1) part2 = match.group(2) result = f"gpt_result/{part2}/{part1}_pass{k}.json" print(result) return result else: print("No match found.") return None # List of input paths input_path_lists = [ # "gpt_result/lean_basic/gpt4/", # "gpt_result/lean_random/gpt4/", "gpt_result/wild/gpt4/", # "gpt_result/lean_basic/gpt3/", # "gpt_result/lean_random/gpt3/", "gpt_result/wild/gpt3/", ] # Iterate through the input paths and run the command for input_path in input_path_lists: k = 5 if "wild" in input_path or "gsm8k_train" in input_path or "math_train" in input_path: print(f"wild") print(f"Running for input path: {input_path}", file=open(output_file, "a")) command = f"python3 gpt_pass_rate_new_notlean_test.py --input_path {input_path} --output_path {get_output(input_path,k)} --k {k}" subprocess.run(command, shell=True, stdout=open(output_file, "a"), stderr=subprocess.STDOUT) print("\n\n",file=open(output_file, "a")) else: print(f"lean") print(f"Running for input path: {input_path}", file=open(output_file, "a")) command = f"python3 gpt_pass_rate_new_test.py --input_path {input_path} --output_path {get_output(input_path, k)} --k {k}" subprocess.run(command, shell=True, stdout=open(output_file, "a"), stderr=subprocess.STDOUT) print("\n\n",file=open(output_file, "a"))