nikdevs commited on
Commit
a2620fd
·
verified ·
1 Parent(s): 84f3a8e

minimax worker: minimax_start.sh

Browse files
Files changed (1) hide show
  1. worker/minimax_start.sh +62 -0
worker/minimax_start.sh ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Boot script for the MiniMax H3 serverless endpoints (fl2va / ref2va).
3
+ # Runs inside runpod/worker-comfyui:*-base before the stock /start.sh:
4
+ # 1. upgrades ComfyUI to a version that supports MiniMax H3 (int8 convrot),
5
+ # 2. wires model files into ComfyUI's model folders — from RunPod's cached
6
+ # model mount when present, otherwise downloads from HF to container disk,
7
+ # 3. installs the lora-from-url custom node.
8
+ set -eo pipefail
9
+
10
+ VARIANT="${MODEL_VARIANT:-fl2va}"
11
+ REPO="nikdevs/minimax-h3-${VARIANT}"
12
+ TARGET="${COMFY_VERSION:-v0.31.0}"
13
+ COMFY=/comfyui
14
+ PY="$(command -v python3 || command -v python)"
15
+
16
+ echo "[minimax] variant=${VARIANT} comfy_target=${TARGET}"
17
+
18
+ # --- 1. ComfyUI version ---------------------------------------------------
19
+ cd "$COMFY"
20
+ CUR="$(git describe --tags --exact-match 2>/dev/null || echo unknown)"
21
+ if [ "$CUR" != "$TARGET" ]; then
22
+ echo "[minimax] upgrading ComfyUI ${CUR} -> ${TARGET}"
23
+ git fetch --depth 1 origin tag "$TARGET" 2>/dev/null || git fetch --tags origin
24
+ git checkout -q "$TARGET"
25
+ "$PY" -m pip install -q -r requirements.txt
26
+ else
27
+ echo "[minimax] ComfyUI already at ${TARGET}"
28
+ fi
29
+
30
+ # --- 2. models ------------------------------------------------------------
31
+ mkdir -p "$COMFY/models/diffusion_models" "$COMFY/models/text_encoders" \
32
+ "$COMFY/models/vae" "$COMFY/models/loras"
33
+
34
+ CACHE_BASE="/runpod-volume/huggingface-cache/hub/models--nikdevs--minimax-h3-${VARIANT}/snapshots"
35
+ SNAP="$(ls -d "$CACHE_BASE"/*/ 2>/dev/null | head -1 || true)"
36
+ if [ -z "$SNAP" ]; then
37
+ echo "[minimax] no runpod model cache — downloading ${REPO} (~54GB) via hf_transfer"
38
+ "$PY" -m pip install -q -U "huggingface_hub[hf_transfer]"
39
+ SNAP="$(HF_HUB_ENABLE_HF_TRANSFER=1 "$PY" - <<PYEOF
40
+ import os
41
+ from huggingface_hub import snapshot_download
42
+ print(snapshot_download("${REPO}", token=os.environ.get("HF_TOKEN")))
43
+ PYEOF
44
+ )"
45
+ fi
46
+ echo "[minimax] model source: ${SNAP}"
47
+ for sub in diffusion_models text_encoders vae; do
48
+ if [ -d "${SNAP}/${sub}" ]; then
49
+ ln -sf "${SNAP}/${sub}"/*.safetensors "$COMFY/models/${sub}/"
50
+ fi
51
+ done
52
+ ls -l "$COMFY/models/diffusion_models" "$COMFY/models/text_encoders" "$COMFY/models/vae"
53
+
54
+ # --- 3. lora-from-url node ------------------------------------------------
55
+ "$PY" - <<'PYEOF'
56
+ import urllib.request
57
+ url = "https://huggingface.co/nikdevs/qwen/resolve/main/worker/lora_from_url.py"
58
+ open("/comfyui/custom_nodes/lora_from_url.py", "wb").write(urllib.request.urlopen(url).read())
59
+ print("[minimax] lora_from_url node installed")
60
+ PYEOF
61
+
62
+ exec /start.sh