feat: resolve relative VIDEO_ARCHIVE_HOST via compose cwd (portable copy-path)
This commit is contained in:
1 parent
7a7393d7a5
commit
a3f2e01c20
3 files changed
+31
-10
No files matched your search
+14
-3
@@ -14,9 +14,20 @@ HF_TOKEN=
|
||||
# Where your recordings live, laid out as <date>/<batch>.mp4. Mounted read-write
|
||||
# into the container; written only by user-initiated upload / date-folder
|
||||
# creation (REQ-178), nothing else.
|
||||
# must be absolute for the copy-path buttons (REQ-179)
|
||||
VIDEO_ARCHIVE_HOST=/absolute/path/to/reTraining/data/archive
|
||||
WSL_DISTRO_NAME=Ubuntu
|
||||
# Relative is recommended — resolved against the directory you start from
|
||||
# (./start.sh cds to the repo root), so this file needs no editing when you
|
||||
# move or clone the project to another machine. Absolute paths also work.
|
||||
VIDEO_ARCHIVE_HOST=./data/archive
|
||||
|
||||
# Copy-path buttons (REQ-179): the Linux button always works from the path
|
||||
# above; the Windows button (\\wsl.localhost\<distro>\...) needs the WSL distro
|
||||
# name. Under WSL the shell already exports WSL_DISTRO_NAME and compose picks
|
||||
# it up automatically — delete this line there (redundant, kept only as a
|
||||
# fallback if your compose run somehow loses the variable).
|
||||
# On a native Linux machine DELETE or leave this commented out: there is no
|
||||
# WSL, and naming a distro would fabricate a bogus Windows path — the button
|
||||
# then simply stays hidden, which is correct.
|
||||
# WSL_DISTRO_NAME=Ubuntu
|
||||
|
||||
# ---- ports ------------------------------------------------------------------
|
||||
|
||||
|
||||
+11
-7
@@ -26,16 +26,20 @@ VIDEO_ROOT = os.path.abspath(os.environ.get("VIDEO_ARCHIVE", os.path.join(DATA_D
|
||||
def archive_host_paths() -> dict:
|
||||
"""Where the archive sits on the host — for the copy-path buttons (REQ-179).
|
||||
|
||||
ponytail: relative VIDEO_ARCHIVE_HOST (./data/archive) cannot be resolved
|
||||
inside the container; set it absolute in .env or the buttons stay hidden."""
|
||||
VIDEO_ARCHIVE_HOST may stay relative (portable across machines): compose
|
||||
injects the host cwd as ARCHIVE_HOST_PWD (compose always has PWD — a
|
||||
Windows-side run yields a drive-letter path, handled below), bare-metal
|
||||
resolves against the process cwd (start.sh cds to the repo root)."""
|
||||
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:
|
||||
if host and not os.path.isabs(host):
|
||||
base = os.environ.get("ARCHIVE_HOST_PWD") or os.getcwd()
|
||||
host = os.path.abspath(os.path.join(base, host))
|
||||
if not host and VIDEO_ROOT != "/videos":
|
||||
host = VIDEO_ROOT # bare-metal with no VIDEO_ARCHIVE_HOST at all
|
||||
if not host:
|
||||
return {"linux": None, "windows": None}
|
||||
linux = host.rstrip("/")
|
||||
if re.match(r"^[A-Za-z]:[\\/]", linux):
|
||||
return {"linux": None, "windows": linux.replace("/", "\\")}
|
||||
distro = os.environ.get("WSL_DISTRO_NAME", "")
|
||||
|
||||
@@ -9,6 +9,12 @@ services:
|
||||
VIDEO_ARCHIVE: /videos
|
||||
CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:5173,http://localhost:9000,http://localhost:9010}
|
||||
VIDEO_ARCHIVE_HOST: ${VIDEO_ARCHIVE_HOST:-./data/archive}
|
||||
# Host working directory — resolves relative VIDEO_ARCHIVE_HOST for the
|
||||
# copy-path buttons (REQ-179). Must be set by running compose from the
|
||||
# repo root; ./start.sh does that cd for you.
|
||||
ARCHIVE_HOST_PWD: ${PWD}
|
||||
# Auto under WSL (shell exports it); empty on native Linux, which hides
|
||||
# the Windows copy-path button — expected.
|
||||
WSL_DISTRO_NAME: ${WSL_DISTRO_NAME:-}
|
||||
volumes:
|
||||
- ./data:/data
|
||||
|
||||
Reference in new issue
Block a user