()
| 565 | # Main Pipeline |
| 566 | # ============================================================================ |
| 567 | def main(): |
| 568 | logger = setup_logging() |
| 569 | args = parse_arguments() |
| 570 | |
| 571 | # ======================================== |
| 572 | # Resume Mode Handling |
| 573 | # ======================================== |
| 574 | resume_state = None |
| 575 | start_round = 1 # Default: start from round 1 |
| 576 | |
| 577 | if args.resume: |
| 578 | logger.info("=" * 80) |
| 579 | logger.info("RESUME MODE ENABLED") |
| 580 | logger.info(f"Resuming from: {args.resume}") |
| 581 | logger.info("=" * 80) |
| 582 | |
| 583 | resume_state = load_resume_state(args.resume, logger) |
| 584 | |
| 585 | if resume_state['completed_rounds'] == 0: |
| 586 | logger.warning("No completed rounds found, starting fresh from round 1") |
| 587 | else: |
| 588 | start_round = resume_state['completed_rounds'] + 1 |
| 589 | logger.info(f"Will resume from round {start_round}") |
| 590 | |
| 591 | # ======================================== |
| 592 | # Setup Task Directory |
| 593 | # ======================================== |
| 594 | # If task is a path (contains / or \), use it directly; otherwise use tasks/{task} |
| 595 | if '/' in args.task or '\\' in args.task or osp.isdir(args.task): |
| 596 | args.task_dir = args.task |
| 597 | args.task_name = osp.basename(args.task.rstrip('/\\')) |
| 598 | else: |
| 599 | args.task_dir = osp.join("tasks", args.task) |
| 600 | args.task_name = args.task |
| 601 | |
| 602 | if not osp.exists(args.task_dir): |
| 603 | raise FileNotFoundError(f"Task directory not found: {args.task_dir}") |
| 604 | |
| 605 | # Detect task type: 'sci' (has task_info.json) or 'auto' (has prompt.json) |
| 606 | args.task_type = detect_task_type(args.task_dir) |
| 607 | |
| 608 | # Setup reference code path |
| 609 | if args.ref_code_path is None: |
| 610 | if args.task_type == 'sci': |
| 611 | args.ref_code_path = None # No reference code for sci tasks |
| 612 | else: |
| 613 | args.ref_code_path = osp.join(args.task_dir, "code") |
| 614 | |
| 615 | # ======================================== |
| 616 | # Setup Output Directory |
| 617 | # ======================================== |
| 618 | if args.resume and resume_state and resume_state['launch_id']: |
| 619 | # Resume mode: use existing launch folder |
| 620 | launch_id = resume_state['launch_id'] |
| 621 | base_output_dir = resume_state['base_output_dir'] |
| 622 | args.output_dir = args.resume |
| 623 | args.base_output_dir = base_output_dir |
| 624 |
no test coverage detected