Scan directories to detect completed rounds when discovery_summary.json is not available. Args: resume_path: Path to the launch folder resume_state: Current resume state dictionary logger: Logger instance Returns: Updated resume state dictionary
(resume_path: str, resume_state: dict, logger)
| 519 | |
| 520 | |
| 521 | def _scan_completed_rounds(resume_path: str, resume_state: dict, logger) -> dict: |
| 522 | """ |
| 523 | Scan directories to detect completed rounds when discovery_summary.json is not available. |
| 524 | |
| 525 | Args: |
| 526 | resume_path: Path to the launch folder |
| 527 | resume_state: Current resume state dictionary |
| 528 | logger: Logger instance |
| 529 | |
| 530 | Returns: |
| 531 | Updated resume state dictionary |
| 532 | """ |
| 533 | # Find all session directories |
| 534 | session_dirs = glob.glob(osp.join(resume_path, "session_*")) |
| 535 | session_dirs.sort() # Sort by name (which includes timestamp) |
| 536 | |
| 537 | completed_rounds = 0 |
| 538 | for session_dir in session_dirs: |
| 539 | session_id = osp.basename(session_dir) |
| 540 | |
| 541 | # Check if this session has completed experiments (has experiment folders with final_info.json) |
| 542 | experiment_folders = [d for d in os.listdir(session_dir) |
| 543 | if osp.isdir(osp.join(session_dir, d)) and not d.startswith('session_')] |
| 544 | |
| 545 | has_completed_experiments = False |
| 546 | for exp_folder in experiment_folders: |
| 547 | # Check for final_info.json in any run folder |
| 548 | run_folders = glob.glob(osp.join(session_dir, exp_folder, "run_*", "final_info.json")) |
| 549 | if run_folders: |
| 550 | has_completed_experiments = True |
| 551 | break |
| 552 | |
| 553 | if has_completed_experiments: |
| 554 | completed_rounds += 1 |
| 555 | resume_state['all_session_ids'].append(session_id) |
| 556 | logger.info(f" Found completed session: {session_id}") |
| 557 | |
| 558 | resume_state['completed_rounds'] = completed_rounds |
| 559 | logger.info(f"Detected {completed_rounds} completed rounds from directory scan") |
| 560 | |
| 561 | return resume_state |
| 562 | |
| 563 | |
| 564 | # ============================================================================ |