| import os |
| import sys |
| from pathlib import Path |
|
|
| from optgs.misc.io import CustomPath |
|
|
| _PKG_DIR = CustomPath(__file__).resolve().parent |
| _REPO_ROOT = _PKG_DIR.parent |
|
|
| |
| _IS_SOURCE_CHECKOUT = (_REPO_ROOT / "pyproject.toml").exists() or (_REPO_ROOT / ".git").exists() |
|
|
| |
| |
| |
| if _IS_SOURCE_CHECKOUT: |
| PROJECT_DIR = CustomPath(str(_REPO_ROOT)) |
| else: |
| PROJECT_DIR = CustomPath(str(os.environ.get("OPTGS_HOME", Path.cwd()))) |
|
|
| SRC_DIR = CustomPath(str(_PKG_DIR)) |
| CKPT_DIR = PROJECT_DIR / "checkpoints" |
| RESULTS_DIR = PROJECT_DIR / "results" |
| FIGURES_DIR = PROJECT_DIR / "figures" |
| DATA_DIR = PROJECT_DIR / "datasets" |
|
|
| DL3DV_480P_DIR = DATA_DIR / "dl3dv-480p-chunks" |
| DL3DV_COLMAP_SfM_DIR = DATA_DIR / "dl3dv-colmap-sfm" |
|
|
| |
| |
| |
| ASSETS_DIR = ( |
| CustomPath(str(os.environ["OPTGS_ASSETS"])) |
| if os.environ.get("OPTGS_ASSETS") |
| else (PROJECT_DIR / "assets") |
| ) |
|
|
|
|
| def asset_path(rel) -> CustomPath: |
| """Resolve an asset file (eval-index JSON, font, ...). |
| |
| Absolute or already-existing paths pass through unchanged. A leading |
| ``assets/`` is stripped so callers may pass either ``assets/x.json`` or |
| ``x.json``. The base dir is ``$OPTGS_ASSETS`` (recommended for installed |
| use), else ``<repo>/assets`` in a source checkout. |
| """ |
| p = Path(str(rel)) |
| if p.is_absolute() or p.exists(): |
| return CustomPath(str(p)) |
| s = str(rel) |
| if s.startswith("assets/"): |
| s = s[len("assets/"):] |
| return CustomPath(str(ASSETS_DIR)) / s |
|
|
|
|
| |
| |
| |
| if _IS_SOURCE_CHECKOUT: |
| try: |
| FIGURES_DIR.mkdir(parents=True, exist_ok=True) |
| except OSError: |
| pass |
|
|
| |
| |
| |
| |
| _debug_env = os.environ.get("OPTGS_DEBUG") |
| if _debug_env is not None: |
| DEBUG = _debug_env.strip().lower() in ("1", "true", "yes", "on") |
| else: |
| DEBUG = sys.gettrace() is not None |
|
|
| if DEBUG: |
| print("Running in debug mode") |
|
|