sf3d's first jobs failed with a 401 from stabilityai/stable-fast-3d. The weights were on the node, and the gate links them into the Hugging Face cache when told the repository — but the agent passed on only the custom nodes, so nothing was linked and the node went to the network for a gated repository. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
100 lines
4.0 KiB
Go
100 lines
4.0 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 TestTheGateIsToldTheNodesAndTheRepositoryTheCatalogGives(t *testing.T) {
|
|
// The repository was dropped on the way: sf3d's node went to the network
|
|
// for its gated repository, with no cache linked, and got a 401.
|
|
c := &ComfyUI{cfg: ComfyUIConfig{Dir: "/opt/comfyui"}}
|
|
cmds, err := c.Commands(ShardSpec{
|
|
ReplicaID: "r-sf3d-1", HTTPPort: 8100, BindAddr: "10.0.0.147", GPUIndices: []int{0},
|
|
Profile: Profile{Name: "p", Engine: "comfyui", ModelPath: "/w/sf3d/", ServedModelName: "sf3d",
|
|
Env: map[string]string{comfyNodesEnv: `[{"repo":"x"}]`, comfyHFRepoEnv: "stabilityai/stable-fast-3d"}},
|
|
})
|
|
if err != nil || len(cmds) != 1 {
|
|
t.Fatalf("%v %v", cmds, err)
|
|
}
|
|
for _, want := range []string{comfyNodesEnv + `=[{"repo":"x"}]`, comfyHFRepoEnv + "=stabilityai/stable-fast-3d"} {
|
|
if !slices.Contains(cmds[0].Env, want) {
|
|
t.Errorf("%q not in the gate's environment", want)
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|