From 712cdeabf18080c0d9f620b14d5d86c5a113414a Mon Sep 17 00:00:00 2001 From: Andrew-AAAA Date: Tue, 29 Sep 2026 08:47:19 +0700 Subject: [PATCH] feat: expose archive host paths in project payload (REQ-172) --- .env.example | 4 +++- backend/config.py | 21 +++++++++++++++++++++ backend/projects.py | 2 ++ docker-compose.yml | 2 ++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 0951e2e..0987f6a 100644 --- a/.env.example +++ b/.env.example @@ -13,7 +13,9 @@ HF_TOKEN= # Where your recordings live, laid out as /.mp4. Mounted read-only # into the container; nothing is ever written back into it. -VIDEO_ARCHIVE_HOST=./data/archive +# must be absolute for the copy-path buttons (REQ-172) +VIDEO_ARCHIVE_HOST=/home/araaraenjoyer/dbs_project/reTraining/data/archive +WSL_DISTRO_NAME=Ubuntu # ---- ports ------------------------------------------------------------------ diff --git a/backend/config.py b/backend/config.py index ca36c8f..fb19211 100644 --- a/backend/config.py +++ b/backend/config.py @@ -22,6 +22,27 @@ DB_PATH = os.path.join(DATA_DIR, "app.db") # they store an absolute one — but this is the default the UI starts browsing from. VIDEO_ROOT = os.path.abspath(os.environ.get("VIDEO_ARCHIVE", os.path.join(DATA_DIR, "archive"))) + +def archive_host_paths() -> dict: + """Where the archive sits on the host — for the copy-path buttons (REQ-172). + + ponytail: relative VIDEO_ARCHIVE_HOST (./data/archive) cannot be resolved + inside the container; set it absolute in .env or the buttons stay hidden.""" + import re + host = os.environ.get("VIDEO_ARCHIVE_HOST", "") + if os.path.isabs(host): + linux = host.rstrip("/") + elif VIDEO_ROOT != "/videos": # bare-metal: VIDEO_ROOT is already the host path + linux = VIDEO_ROOT + else: + return {"linux": None, "windows": None} + if re.match(r"^[A-Za-z]:[\\/]", linux): + return {"linux": None, "windows": linux.replace("/", "\\")} + distro = os.environ.get("WSL_DISTRO_NAME", "") + windows = f"\\\\wsl.localhost\\{distro}\\" + linux.lstrip("/").replace("/", "\\") if distro else None + return {"linux": linux, "windows": windows} + + # Vite dev server needs cross-origin access; in Docker nginx proxies /api and # this is irrelevant. CORS_ORIGINS = [ diff --git a/backend/projects.py b/backend/projects.py index 23ff4fb..89a96e1 100644 --- a/backend/projects.py +++ b/backend/projects.py @@ -178,6 +178,8 @@ def _row_to_dict(cur, row) -> dict: "secondary_model_classes": sec_classes, "base_model_fallback": PRETRAINED[row["label_type"]], "video_root": row["video_root"], + "video_root_linux": config.archive_host_paths()["linux"], + "video_root_windows": config.archive_host_paths()["windows"], "val_every": row["val_every"], "created_at": row["created_at"], "classes": classes, diff --git a/docker-compose.yml b/docker-compose.yml index 28109da..75f9b99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,8 @@ services: APP_DATA_DIR: /data VIDEO_ARCHIVE: /videos CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:5173,http://localhost:9000,http://localhost:9010} + VIDEO_ARCHIVE_HOST: ${VIDEO_ARCHIVE_HOST:-./data/archive} + WSL_DISTRO_NAME: ${WSL_DISTRO_NAME:-} volumes: - ./data:/data - ${VIDEO_ARCHIVE_HOST:-./data/archive}:/videos:ro