flux and sf3d on one card handed it to each other, each starting ComfyUI and loading its weights from nothing (BACKLOG H3, placement side). An environment of two or more models now gets a hidden catalog entry, comfyui-env-<name>: on its first member's profiles with the most memory any member needs, on demand for the longest idle timeout, carrying every member's weights, repositories and the environment's custom nodes. The members get no replicas of their own; asking for one wants the entry. The agent fetches each member's weights; the gate links all of them, refusing two weights files of one name, links each member's Hugging Face repository, and answers /v1/models for every member. The control plane offers the replica under the members' names with each one's workflow and checkpoint, which the router sends by the model asked for. A member's sibling never evicts the replica serving it, and the members' load counts as the entry's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package catalog
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestAnEnvironmentOfTwoGetsOneHiddenEntryThatServesBoth(t *testing.T) {
|
|
// flux and a mesh model on one card took turns, each loading ComfyUI
|
|
// from nothing; in one environment one replica answers for both.
|
|
flux := comfyModel("/w/flux.safetensors", &ComfyUI{Environment: "art", Workflow: "flux-schnell"})
|
|
flux.Scaling = Scaling{Max: 1, IdleTimeout: 15 * time.Minute}
|
|
sf3d := inEnv("sf3d", "art", "/w/sf3d/", CustomNode{Repo: "https://example.com/sf3d", Commit: commitA})
|
|
sf3d.ComfyUI.HuggingFaceRepo = "stabilityai/stable-fast-3d"
|
|
sf3d.ComfyUI.Checkpoint = "model.safetensors"
|
|
sf3d.Scaling = Scaling{Max: 1, IdleTimeout: 10 * time.Minute}
|
|
cat, err := New([]Model{flux, sf3d, inEnv("alone", "solo", "/w/alone.ckpt")})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
host, ok := cat.SharedBy("sf3d")
|
|
if !ok || host != "comfyui-env-art" {
|
|
t.Fatalf("sf3d shared by %q %v", host, ok)
|
|
}
|
|
if _, ok := cat.SharedBy("alone"); ok {
|
|
t.Error("an environment of one got a hidden entry")
|
|
}
|
|
em, _ := cat.Resolve(host)
|
|
if !em.IsEnvironment() || em.MakesImages() || em.MakesMeshes() || em.Scaling.IdleTimeout != 15*time.Minute ||
|
|
len(em.Shared.Members) != 2 || em.Shared.Members[1].HFRepo != "stabilityai/stable-fast-3d" {
|
|
t.Errorf("entry %+v", em)
|
|
}
|
|
p, ok := em.EngineProfile(em.Profiles[0].Name)
|
|
if !ok {
|
|
t.Fatal("no engine profile")
|
|
}
|
|
var ms []map[string]string
|
|
if err := json.Unmarshal([]byte(p.Env[SharedModelsEnv]), &ms); err != nil || len(ms) != 2 || ms[1]["source"] != "/w/sf3d/" {
|
|
t.Errorf("members for the agent %q %v", p.Env[SharedModelsEnv], err)
|
|
}
|
|
if !strings.Contains(p.Env[NodesEnv], "sf3d") {
|
|
t.Errorf("nodes %q", p.Env[NodesEnv])
|
|
}
|
|
// A catalog built again from its own models is the same catalog.
|
|
again, err := New(cat.Models())
|
|
if err != nil || len(again.Models()) != len(cat.Models()) {
|
|
t.Errorf("rebuilt: %v, %d models vs %d", err, len(again.Models()), len(cat.Models()))
|
|
}
|
|
}
|