Get all incorrect tasks by combining experiment results with benchmark data. Args: experiment_file: Path to the experiment results JSON file benchmark_name: Name of the benchmark to load tasks from Returns: List of task_data objects for incorrect samples
(experiment_file: str, benchmark_name: str)
| 261 | return tasks |
| 262 | |
| 263 | async def get_all_incorrect_tasks(experiment_file: str, benchmark_name: str) -> List[Any]: |
| 264 | """ |
| 265 | Get all incorrect tasks by combining experiment results with benchmark data. |
| 266 | |
| 267 | Args: |
| 268 | experiment_file: Path to the experiment results JSON file |
| 269 | benchmark_name: Name of the benchmark to load tasks from |
| 270 | |
| 271 | Returns: |
| 272 | List of task_data objects for incorrect samples |
| 273 | """ |
| 274 | # Load experiment results to find incorrect task_ids |
| 275 | print(f"Loading experiment results from: {experiment_file}") |
| 276 | with open(experiment_file, 'r', encoding='utf-8') as f: |
| 277 | experiment_data = json.load(f) |
| 278 | |
| 279 | all_results = experiment_data.get('results', []) |
| 280 | incorrect_samples = [sample for sample in all_results if not sample.get('correct', True)] |
| 281 | |
| 282 | # Extract incorrect task_ids |
| 283 | incorrect_task_ids = {sample['task_id'] for sample in incorrect_samples} |
| 284 | print(f"Found {len(incorrect_task_ids)} incorrect task_ids") |
| 285 | |
| 286 | all_tasks = await get_all_tasks(benchmark_name) |
| 287 | |
| 288 | # Create task_id to task mapping |
| 289 | task_map = {} |
| 290 | for task in all_tasks: |
| 291 | task_id = getattr(task, 'task_id', None) |
| 292 | if task_id: |
| 293 | task_map[task_id] = task |
| 294 | |
| 295 | # Find incorrect task_data objects |
| 296 | incorrect_tasks = [] |
| 297 | found_count = 0 |
| 298 | |
| 299 | for task_id in incorrect_task_ids: |
| 300 | if task_id in task_map: |
| 301 | incorrect_tasks.append(task_map[task_id]) |
| 302 | found_count += 1 |
| 303 | print(f"Found incorrect task: {task_id}") |
| 304 | else: |
| 305 | print(f"Warning: Could not find task_data for task_id {task_id}") |
| 306 | |
| 307 | print(f"Successfully retrieved {found_count} incorrect task_data objects out of {len(incorrect_task_ids)}") |
| 308 | |
| 309 | return incorrect_tasks |
| 310 | |
| 311 | async def process_single_task(optimizer_type: str, benchmark_name: str, task_data: Any, task_index: int, total_tasks: int, result_saver: ExperimentResultSaver = None): |
| 312 | """Process a single task with the optimizer.""" |
no test coverage detected