Gather all solutions from the folders
(sample_path: str, task_id: str)
| 90 | |
| 91 | |
| 92 | def gather_solutions(sample_path: str, task_id: str) -> List[str]: |
| 93 | """Gather all solutions from the folders""" |
| 94 | solutions = [] |
| 95 | for model in os.listdir(sample_path): |
| 96 | model_path = os.path.join(sample_path, model) |
| 97 | if not os.path.isdir(model_path): |
| 98 | continue |
| 99 | task_path = os.path.join(model_path, task_id) |
| 100 | if os.path.isdir(task_path): |
| 101 | for file in os.listdir(task_path): |
| 102 | if file.endswith(".py"): |
| 103 | with open(os.path.join(task_path, file), "r") as f: |
| 104 | solutions.append(f.read()) |
| 105 | return solutions |
| 106 | |
| 107 | |
| 108 | def deduplicate(solutions: List[str]) -> List[str]: |