File size: 1,225 Bytes
8ca7ba0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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:])