You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
"""Path utilities for experiment outputs."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
# Base directories
|
|
BASE_DIR = Path(__file__).parent.parent
|
|
RESULTS_DIR = BASE_DIR / "results"
|
|
|
|
|
|
def ensure_dir(path: Path) -> Path:
|
|
"""Create directory if it doesn't exist."""
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
return path
|
|
|
|
|
|
def get_results_dir() -> Path:
|
|
"""Get base results directory."""
|
|
return ensure_dir(RESULTS_DIR)
|
|
|
|
|
|
def get_task_results_dir(task_name: str) -> Path:
|
|
"""Get results directory for a specific task."""
|
|
return ensure_dir(RESULTS_DIR / task_name)
|
|
|
|
|
|
def create_experiment_dir(task_name: str, experiment_name: str | None = None) -> Path:
|
|
"""Create a timestamped directory for an experiment.
|
|
|
|
Args:
|
|
task_name: Name of the task (e.g., 'cta_1d', 'stock_15m')
|
|
experiment_name: Optional experiment name (default: timestamp)
|
|
|
|
Returns:
|
|
Path to the created directory
|
|
"""
|
|
if experiment_name is None:
|
|
experiment_name = datetime.now().strftime('%Y%m%d_%H%M%S')
|
|
|
|
exp_dir = RESULTS_DIR / task_name / experiment_name
|
|
return ensure_dir(exp_dir)
|