Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): let pip resolve mflux's deps instead of a hand-kept list

[._.]/ Adam Eivyb94318bf7e04
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 32c558c971..6902869294 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -18,7 +18,7 @@
## Fixed
-- **LoRA training that died with a bare "exited with code 2" now says what actually broke — and a stale mflux fails loudly instead** — A FLUX.2 LoRA training run could fail instantly with the useless message `Training exited with code 2 — ❌ mflux trainer exited with code 2`. The real cause was a stale **mflux 0.12.x** in the local image-gen venv: that version predates FLUX.2 LoRA training, so its `mflux-train` CLI rejected the wrapper's `--config` flag (it wants `--train-config`) and had no `flux2-klein-*` base models — argparse exited 2 before any work began. The actual argparse error was lost because the wrapper merges mflux's stderr into stdout, leaving the Node failure classifier's stderr window empty. Two fixes: (1) on a non-zero exit the wrapper now replays the trainer's last ~40 output lines to stderr (so tracebacks, argparse errors, and version-mismatch complaints reach the classifier instead of vanishing), and a new `CLI_MISMATCH` classification turns the argparse rejection into an actionable *"your mflux is too old for FLUX.2 LoRA training — `pip install -U 'mflux>=0.17'`"*; (2) `scripts/setup-image-video.sh` now pins **`mflux>=0.17`** (the first release with FLUX.2 training) and the matching **`transformers>=5,<6`** mflux 0.17+ requires — the old `transformers<5` pin would have broken the newer mflux on import. (`scripts/train_mflux_lora.py`, `server/services/loraTraining/failure.js`, `scripts/setup-image-video.sh`)
+- **LoRA training that died with a bare "exited with code 2" now says what actually broke — and a stale mflux fails loudly instead** — A FLUX.2 LoRA training run could fail instantly with the useless message `Training exited with code 2 — ❌ mflux trainer exited with code 2`. The real cause was a stale **mflux 0.12.x** in the local image-gen venv: that version predates FLUX.2 LoRA training, so its `mflux-train` CLI rejected the wrapper's `--config` flag (it wants `--train-config`) and had no `flux2-klein-*` base models — argparse exited 2 before any work began. The actual argparse error was lost because the wrapper merges mflux's stderr into stdout, leaving the Node failure classifier's stderr window empty. Two fixes: (1) on a non-zero exit the wrapper now replays the trainer's last ~40 output lines to stderr (so tracebacks, argparse errors, and version-mismatch complaints reach the classifier instead of vanishing), and a new `CLI_MISMATCH` classification turns the argparse rejection into an actionable *"your mflux is too old for FLUX.2 LoRA training — `pip install -U 'mflux>=0.17'`"*; (2) `scripts/setup-image-video.sh` now pins **`mflux>=0.17`** (the first release with FLUX.2 training) and lets pip resolve mflux's declared runtime deps instead of a hand-kept list — mflux 0.17 imports packages the old list omitted (pillow, matplotlib, platformdirs, sentencepiece, …) and constrains `transformers>=5,<6` and `mlx<0.32`, so the stale list (which pinned `transformers<5` and an unbounded `mlx`) would have left `mflux-train` failing at import. (`scripts/train_mflux_lora.py`, `server/services/loraTraining/failure.js`, `scripts/setup-image-video.sh`)
- **Concurrent LoRA caption runs no longer fan out parallel requests at a single-GPU backend** — Within one run the captioner already processes images one at a time, but nothing stopped several runs from overlapping (captioning two datasets at once, re-captioning multiple single images, or a double-click). Each run is a detached loop, so concurrent runs fired N parallel `/chat/completions` requests at the same local Ollama/LM Studio — and on one GPU that's pure downside: every Ollama parallel slot reserves its own 32K-token KV cache, so concurrent vision requests multiply VRAM and risk an OOM or model reload, while parallel decoding gives no throughput win (it just time-slices the same compute and makes each request slower). A module-level mutex now serializes every caption vision call across all runs, holding backend load at concurrency 1 regardless of how many runs are in flight. One-shot vision calls (voice `ui_describe_visually`, the vision-test page) stay off the lock so a long batch run can't FIFO-starve an interactive describe. (`server/services/loraDatasetCaption.js`)
diff --git a/scripts/setup-image-video.sh b/scripts/setup-image-video.sh
index d3039a3fac..3a27d20559 100755
--- a/scripts/setup-image-video.sh
+++ b/scripts/setup-image-video.sh
@@ -83,23 +83,21 @@ if [[ "$INSTALL_MFLUX" == "1" ]]; then
# mflux (0.12.x) wants `--train-config` and has no flux2 models, so its
# trainer dies with a bare "exited with code 2" — see train_mflux_lora.py.
#
- # `--force-reinstall --no-deps` on mflux only — earlier setup runs could
- # leave the user-site copy at the right version number but with stale file
- # layout (we hit this in 0.12.1, where `mflux/models/flux/cli/` was missing
- # from a partial reinstall, breaking the entry-point shim). Forcing the
- # reinstall flushes the file tree without re-resolving torch/mlx and friends.
echo "📦 Installing image generation packages (mflux + deps)..."
+ # Step 1: force-reinstall mflux's OWN files with --no-deps to flush a stale
+ # file layout left by a partial reinstall (we hit this on 0.12.1, where
+ # `mflux/models/flux/cli/` went missing, breaking the entry-point shim)
+ # WITHOUT re-downloading the heavy torch/mlx tree.
"$PYTHON_BIN" -m pip install --upgrade --user --force-reinstall --no-deps 'mflux>=0.17'
- # mflux above is installed with --no-deps to flush its file tree without
- # re-resolving torch/mlx — but that means we must explicitly install mflux's
- # own runtime deps here (notably `mlx` on macOS, which it imports at startup).
- # Without this, INSTALL_VIDEO=0 leaves mflux unable to import. mflux >=0.17
- # requires transformers 5.x (>=5,<6) — the old <5 pin breaks it on import.
- MFLUX_DEPS=("transformers>=5,<6" safetensors huggingface_hub numpy opencv-python tqdm)
- if is_macos; then
- MFLUX_DEPS+=(mlx)
- fi
- "$PYTHON_BIN" -m pip install --upgrade --user "${MFLUX_DEPS[@]}"
+ # Step 2: let pip install mflux's DECLARED runtime deps — pip is the source
+ # of truth, not a hand-kept list. mflux 0.17 imports packages the 0.12.x set
+ # omitted (pillow, matplotlib, platformdirs, sentencepiece, piexif, …) and
+ # constrains transformers>=5,<6 and mlx<0.32; a hand list silently drifts and
+ # leaves `mflux-train` failing at import before it can reach the trainer.
+ # No --no-deps (so missing deps ARE pulled) and no --upgrade (so an
+ # already-satisfied heavyweight like torch isn't re-resolved/re-downloaded on
+ # repeat runs); a dep that violates mflux's constraints is still corrected.
+ "$PYTHON_BIN" -m pip install --user 'mflux>=0.17'
fi
if [[ "$INSTALL_VIDEO" == "1" ]]; then