|
26 | 26 | from typing import Dict, List, Tuple, Any, Optional |
27 | 27 |
|
28 | 28 |
|
| 29 | +def get_openevolve_output_dir(): |
| 30 | + """Get the OpenEvolve output directory, creating it if needed""" |
| 31 | + # Look for openevolve_output in current directory or parent directories |
| 32 | + current_dir = os.path.dirname(os.path.abspath(__file__)) |
| 33 | + |
| 34 | + # Check current directory first |
| 35 | + output_dir = os.path.join(current_dir, "openevolve_output") |
| 36 | + if not os.path.exists(output_dir): |
| 37 | + # Check parent directory (common case) |
| 38 | + parent_dir = os.path.dirname(current_dir) |
| 39 | + parent_output_dir = os.path.join(parent_dir, "openevolve_output") |
| 40 | + if os.path.exists(parent_output_dir): |
| 41 | + output_dir = parent_output_dir |
| 42 | + else: |
| 43 | + # Create in current directory if neither exists |
| 44 | + output_dir = os.path.join(current_dir, "openevolve_output") |
| 45 | + |
| 46 | + # Ensure it exists |
| 47 | + os.makedirs(output_dir, exist_ok=True) |
| 48 | + return output_dir |
| 49 | + |
| 50 | + |
| 51 | +def get_baseline_output_dir(): |
| 52 | + """Get the baseline output directory within openevolve_output""" |
| 53 | + baseline_dir = os.path.join(get_openevolve_output_dir(), "baseline") |
| 54 | + os.makedirs(baseline_dir, exist_ok=True) |
| 55 | + return baseline_dir |
| 56 | + |
| 57 | + |
| 58 | +def get_evaluation_output_dir(): |
| 59 | + """Get the evaluation output directory within openevolve_output""" |
| 60 | + eval_dir = os.path.join(get_openevolve_output_dir(), "evaluation") |
| 61 | + os.makedirs(eval_dir, exist_ok=True) |
| 62 | + return eval_dir |
| 63 | + |
| 64 | + |
29 | 65 | def load_baseline_results() -> Optional[Dict[str, Any]]: |
30 | 66 | """Load baseline results if available""" |
31 | 67 | baseline_results_path = os.path.join( |
|
0 commit comments