from __future__ import annotations import os from pathlib import Path PROJECT_ROOT = Path(__file__).resolve().parents[2] def data_root() -> Path: """Return the external artifact root; never default inside the code checkout.""" configured = os.environ.get("RHG_DATA_ROOT") root = Path(configured).expanduser() if configured else PROJECT_ROOT.parent / "RoboHouseGenData" return root.resolve() def runs_root() -> Path: configured = os.environ.get("RHG_RUNS_ROOT") root = Path(configured).expanduser() if configured else data_root() / "runs" return root.resolve() def api_runs_root() -> Path: configured = os.environ.get("RHG_RUN_ROOT") root = Path(configured).expanduser() if configured else runs_root() / "api" return root.resolve() def media_root() -> Path: configured = os.environ.get("RHG_MEDIA_ROOT") root = Path(configured).expanduser() if configured else data_root() / "media" return root.resolve() def resolve_run_path(path: Path) -> Path: """Map conventional ``runs/...`` paths to the external runs root.""" if path.is_absolute() or not path.parts or path.parts[0] != "runs": return path return runs_root().joinpath(*path.parts[1:])