engines.comfyui in the cluster's settings has every NVIDIA node build ComfyUI: the release's source archive from GitHub, checked against the digest the recipe holds — GitHub publishes none for a tag's archive, so a version without one is refused — unpacked beside a Python environment whose dependencies are its requirements file resolved as PyPI stood the day after the release. torch is PyPI's CUDA 13 build, or PyTorch's CUDA 12.9 one on an older driver, and the install is checked on the card. A requirements file that names anything but PyPI packages is refused. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
81 lines
3.1 KiB
Go
81 lines
3.1 KiB
Go
package engines
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestComfyUIRunsBehindTheGateWithItsKeyOutOfSight(t *testing.T) {
|
|
c := &ComfyUI{cfg: ComfyUIConfig{Dir: "/opt/comfyui"}}
|
|
cmds, err := c.Commands(ShardSpec{
|
|
ReplicaID: "r-flux-1", HTTPPort: 8100, BindAddr: "10.0.0.147", APIKey: "sekret", GPUIndices: []int{0},
|
|
Profile: Profile{Name: "p", Engine: "comfyui", ModelPath: "/w/flux.safetensors", ServedModelName: "flux",
|
|
Args: []string{"--disable-smart-memory"}},
|
|
})
|
|
if err != nil || len(cmds) != 1 {
|
|
t.Fatalf("%v %v", cmds, err)
|
|
}
|
|
args := strings.Join(cmds[0].Args, " ")
|
|
for _, want := range []string{"comfyui-gate", "--listen 10.0.0.147:8100", "--model flux", "--weights /w/flux.safetensors",
|
|
"--state comfyui/r-flux-1", "--python /opt/comfyui/.venv/bin/python", "--comfyui /opt/comfyui", "-- --disable-smart-memory"} {
|
|
if !strings.Contains(args, want) {
|
|
t.Errorf("%q not in %q", want, args)
|
|
}
|
|
}
|
|
if strings.Contains(args, "sekret") {
|
|
t.Error("the key is on the command line, where every user can read it")
|
|
}
|
|
if !slices.Contains(cmds[0].Env, "LLMGW_ENGINE_KEY=sekret") || !slices.Contains(cmds[0].Env, "CUDA_VISIBLE_DEVICES=0") {
|
|
t.Error("the key or the card is not in the environment")
|
|
}
|
|
}
|
|
|
|
func TestComfyUIRunsOnOneCard(t *testing.T) {
|
|
c := &ComfyUI{}
|
|
if err := c.Validate(Profile{Name: "p", ModelPath: "/w", TP: 2}, h100(2)); err == nil {
|
|
t.Error("a two-card ComfyUI profile was accepted")
|
|
}
|
|
if err := c.Validate(Profile{Name: "p", ModelPath: "/w", TP: 1}, h100(1)); err != nil {
|
|
t.Error(err)
|
|
}
|
|
if _, err := c.Commands(ShardSpec{Profile: Profile{ModelPath: "/w"}}); err == nil {
|
|
t.Error("commands without a ComfyUI directory")
|
|
}
|
|
}
|
|
|
|
func TestComfyUIIsOfferedByTheVersionItsBuildWrote(t *testing.T) {
|
|
dir := t.TempDir()
|
|
c := &ComfyUI{cfg: ComfyUIConfig{Dir: dir}}
|
|
if _, err := c.Probe(t.Context()); err == nil {
|
|
t.Error("a directory without main.py passed for ComfyUI")
|
|
}
|
|
_ = os.WriteFile(filepath.Join(dir, "main.py"), nil, 0o644)
|
|
_ = os.WriteFile(filepath.Join(dir, "comfyui_version.py"), []byte("__version__ = \"0.39.2\"\n"), 0o644)
|
|
if v, err := c.Probe(t.Context()); err != nil || v != "0.39.2" {
|
|
t.Errorf("%q %v", v, err)
|
|
}
|
|
if got := NewRegistry(Config{ComfyUI: ComfyUIConfig{Dir: dir}}).ProbeConfigured(t.Context()); got["comfyui"] != "0.39.2" {
|
|
t.Errorf("a configured ComfyUI is reported as %v", got)
|
|
}
|
|
if err := UnsafeArgs("comfyui", []string{"--enable-manager"}); err == nil {
|
|
t.Error("a profile may install ComfyUI nodes")
|
|
}
|
|
}
|
|
|
|
func TestAnInstalledComfyUIIsFoundBesideItsInterpreter(t *testing.T) {
|
|
c := &ComfyUI{cfg: ComfyUIConfig{Dir: "/opt/by-hand"}}
|
|
c.UseInstalled("/opt/llmgw/engines/comfyui/0.39.2-cu13/bin/python")
|
|
cmds, err := c.Commands(ShardSpec{ReplicaID: "r", HTTPPort: 1, Profile: Profile{ModelPath: "/w", ServedModelName: "m"}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
args := strings.Join(cmds[0].Args, " ")
|
|
if !strings.Contains(args, "--python /opt/llmgw/engines/comfyui/0.39.2-cu13/bin/python") ||
|
|
!strings.Contains(args, "--comfyui /opt/llmgw/engines/comfyui/0.39.2-cu13/comfyui") {
|
|
t.Errorf("the installed ComfyUI is not what runs: %s", args)
|
|
}
|
|
}
|