video_editor: auto-load mapped config + --map accepts files

Mirror the township config fix for the bundled video editor:
* supervisord: pass --config /cache/video_editor/video_editor.config.json so a
  bind-mounted (or cache-persisted) config auto-loads — previously it only
  auto-loaded video_editor.config.json from the baked cwd, which isn't mappable.
* video_editor.py: a MISSING --config file is no longer fatal (was raise
  SystemExit) — start with defaults; the web UI Save creates it.
* entrypoint: pre-create /cache/video_editor so the config dir exists for
  auto-load + web-UI Save (persists on the standard /cache volume by default).
* run_oci.sh (coderai-docker): --map now accepts a single FILE, not just a dir,
  so a tool config that lives loose on the host can be linked directly, e.g.
  --map /host/video_editor.config.json:/cache/video_editor/video_editor.config.json

Bump version to 0.1.5.
Co-Authored-By: 's avatarClaude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RdMufYvtTbtGDWsiZVoXce
parent fadc340d
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# Canonical product version for CoderAI — single source of truth. Both the API # Canonical product version for CoderAI — single source of truth. Both the API
# metadata and the admin web UI read from here. # metadata and the admin web UI read from here.
__version__ = "0.1.4" __version__ = "0.1.5"
# Configure the CUDA caching allocator BEFORE torch is imported anywhere. # Configure the CUDA caching allocator BEFORE torch is imported anywhere.
# expandable_segments lets the allocator return freed pages to the driver even # expandable_segments lets the allocator return freed pages to the driver even
......
...@@ -34,6 +34,7 @@ mkdir -p \ ...@@ -34,6 +34,7 @@ mkdir -p \
"$CODERAI_CACHE_DIR/coderai" \ "$CODERAI_CACHE_DIR/coderai" \
"$CODERAI_CACHE_DIR/township_output" \ "$CODERAI_CACHE_DIR/township_output" \
"$CODERAI_CACHE_DIR/videogen_output" \ "$CODERAI_CACHE_DIR/videogen_output" \
"$CODERAI_CACHE_DIR/video_editor" \
"$CODERAI_TMP" \ "$CODERAI_TMP" \
/tmp/nginx-client-body /tmp/nginx-proxy /tmp/nginx-fastcgi \ /tmp/nginx-client-body /tmp/nginx-proxy /tmp/nginx-fastcgi \
/tmp/nginx-uwsgi /tmp/nginx-scgi /tmp/nginx-uwsgi /tmp/nginx-scgi
......
...@@ -132,9 +132,11 @@ Options: ...@@ -132,9 +132,11 @@ Options:
root-owned, and --config-dir/--local use a throwaway copy root-owned, and --config-dir/--local use a throwaway copy
(no persistence) to avoid root-owned config. (no persistence) to avoid root-owned config.
--inplace-config Mount --config-dir in place (config edits persist there). --inplace-config Mount --config-dir in place (config edits persist there).
--map HOST[:CONT] Bind-mount a host dir at the SAME path (or HOST:CONT) inside --map HOST[:CONT] Bind-mount a host dir OR file at the SAME path (or HOST:CONT)
the container, so absolute paths in models.json resolve inside the container, so absolute paths in models.json (or a
(e.g. --map /AI/guffcache). Repeatable. tool's config) resolve (e.g. --map /AI/guffcache, or
--map /host/video_editor.config.json:/cache/video_editor/video_editor.config.json).
Repeatable.
--debug[=SPEC] Run coderai with debug flags. SPEC (default 'all'); may be --debug[=SPEC] Run coderai with debug flags. SPEC (default 'all'); may be
given as --debug=SPEC or --debug SPEC: given as --debug=SPEC or --debug SPEC:
all | engine,requests,ws,web,thermal,lora,engine-web all | engine,requests,ws,web,thermal,lora,engine-web
...@@ -403,7 +405,9 @@ fi ...@@ -403,7 +405,9 @@ fi
for m in "${MAPS[@]:-}"; do for m in "${MAPS[@]:-}"; do
[[ -n "$m" ]] || continue [[ -n "$m" ]] || continue
host="${m%%:*}"; cont="${m#*:}"; [[ "$m" == *:* ]] || cont="$host" host="${m%%:*}"; cont="${m#*:}"; [[ "$m" == *:* ]] || cont="$host"
if [[ -d "$host" ]]; then if [[ -e "$host" ]]; then
# Accept a directory OR a single file (e.g. a tool's config.json that lives
# loose on the host rather than in a dedicated dir). Docker bind-mounts both.
args+=(-v "$host:$cont$volume_suffix") args+=(-v "$host:$cont$volume_suffix")
else else
echo "Warning: --map source '$host' not found; skipping" >&2 echo "Warning: --map source '$host' not found; skipping" >&2
......
...@@ -53,6 +53,7 @@ redirect_stderr=true ...@@ -53,6 +53,7 @@ redirect_stderr=true
command=/usr/local/bin/with-env /opt/coderai/python/bin/python3 /opt/coderai/app/tools/video_editor.py command=/usr/local/bin/with-env /opt/coderai/python/bin/python3 /opt/coderai/app/tools/video_editor.py
--no-browser --host 127.0.0.1 --port 8420 --no-browser --host 127.0.0.1 --port 8420
--base-url http://127.0.0.1:18776 --base-url http://127.0.0.1:18776
--config /cache/video_editor/video_editor.config.json
directory=/opt/coderai/app directory=/opt/coderai/app
autostart=%(ENV_CODERAI_TOOL_VIDEO_EDITOR)s autostart=%(ENV_CODERAI_TOOL_VIDEO_EDITOR)s
autorestart=true autorestart=true
......
...@@ -4041,14 +4041,21 @@ def main(): ...@@ -4041,14 +4041,21 @@ def main():
if args.config: if args.config:
cfg_path = Path(args.config).expanduser() cfg_path = Path(args.config).expanduser()
if not cfg_path.is_file(): if not cfg_path.is_file():
raise SystemExit(f"--config file not found: {cfg_path}") # Not fatal: the bundled launcher always points --config at
try: # /cache/video_editor/video_editor.config.json so a bind-mounted config
loaded = json.loads(cfg_path.read_text(encoding="utf-8")) # auto-loads, but on a fresh install (no mapped/saved config yet) the
except (json.JSONDecodeError, OSError) as e: # file isn't there — start with defaults; the web UI Save creates it.
raise SystemExit(f"Could not read config {cfg_path}: {e}") print(f"ℹ Config {cfg_path} not found — starting with defaults "
for k in SETTINGS_KEYS: "(it'll be created when you Save from the web UI).",
if loaded.get(k) is not None: file=sys.stderr)
settings[k] = loaded[k] else:
try:
loaded = json.loads(cfg_path.read_text(encoding="utf-8"))
except (json.JSONDecodeError, OSError) as e:
raise SystemExit(f"Could not read config {cfg_path}: {e}")
for k in SETTINGS_KEYS:
if loaded.get(k) is not None:
settings[k] = loaded[k]
cli = { cli = {
"media_dir": args.media_dir, "output_dir": args.output_dir, "media_dir": args.media_dir, "output_dir": args.output_dir,
"base_url": args.base_url, "api_key": args.api_key, "base_url": args.base_url, "api_key": args.api_key,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment