feat(lora-worker): Phase 2 publish-step — copy succeeded LoRA into ComfyUI loras + published_lora_name

On a train reaching succeeded, IN ADDITION to output/{name}.safetensors
(unchanged download source), COPY it into ComfyUI's loras search path at
/storetank/arbo/models/loras/trained/{train_id}/{name}.safetensors and
return published_lora_name (the ComfyUI-relative LoraLoader string) in the
terminal GET /train/{id} payload (arbo Phase 2 auto-registration, §4.1/§7).

- Copy not move; a publish failure NEVER fails the train (keeps succeeded,
  omits published_lora_name, logs the reason to the tailable run log).
- INV-T7-safe: a copy to a fixed computed path, no new free-form args.
- train_id derived from the handoff layout (output_dir.parent.name).
- Provisions loras/trained/ (arbotrain 2775, group-write per the Phase-1
  lesson; world-readable/traversable for ComfyUI) via the deploy playbook.
- ComfyUI verified to resolve nested loras subfolders (no flat fallback).
- Pure path helper unit-tested; 16 tests green.
This commit is contained in:
vh
2026-07-07 00:22:20 -07:00
parent f5c628c56d
commit 74dbfafdf1
5 changed files with 81 additions and 2 deletions
@@ -51,6 +51,17 @@ ALLOWED_MODEL_ROOTS = tuple(
if p
)
# ---- LoRA publish step (Phase 2 — auto-registration into ComfyUI Generate) -------------
# On a train reaching `succeeded`, IN ADDITION to output/{name}.safetensors (the unchanged
# download source), the worker COPIES the LoRA into ComfyUI's loras search path under
# PUBLISH_SUBDIR/{train_id}/ and reports `published_lora_name` (the path RELATIVE to the
# loras root — the exact string a ComfyUI LoraLoader.lora_name widget takes). ComfyUI
# (verified 2026-07-07) resolves loras SUBfolders, so the nested scheme works. A publish
# failure NEVER fails the train — it just omits published_lora_name (download still works).
# Stays inside INV-T7 (a copy to a fixed computed path; no new free-form args).
LORAS_PUBLISH_ROOT = Path(os.environ.get("LORA_WORKER_LORAS_ROOT", "/storetank/arbo/models/loras"))
PUBLISH_SUBDIR = "trained" # loras/trained/{train_id}/{name}.safetensors
# ---- Worker state + logs (survives a worker restart for boot reconciliation, §4.3) -----
STATE_DIR = Path(os.environ.get("LORA_WORKER_STATE_DIR", "/opt/lora-training-worker/state"))
LOG_DIR = Path(os.environ.get("LORA_WORKER_LOG_DIR", "/opt/lora-training-worker/logs"))