Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Merge main's newer work (a waiting step of a longer run stops instead of moving after a restart, Fuobe Connect, Set it up with my AI from the phone, pinned cut-out model files, clean Idol orbits)

Adarshfb0fb7c76088
diff --cc src/server/generations.ts
index a82dd47e,40c2c02f..356fc407
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@@ -3325,14 -3174,7 +3333,8 @@@ function takeOver(r: Pick<Row, "id" | "
// Planned for another provider now (its GPU disconnected, another key): its polls would ask the provider it was made
// for, so it stops, as a run whose GPU changed while it waited does.
if (p.providerId !== r.provider) {
- if (r.provider === "comfyui") {
- const gpu = accountGpu(account);
- const end = diagnoseGpuJob({ kind: gpu ? "moved" : "disconnected" }, { kind: "link", url: gpuLink(gpu)?.url ?? "" });
- failRun(r.id, new Error("moved"), end, account, { provider: r.provider, model: p.plan.model.id, op: p.plan.op, stage: "submit" });
- } else if (updateLive(r.id, { status: "failed", error: "This run stopped because your keys changed while it waited. Press Retry.", completed_at: Date.now(), message: null }, " AND external_id IS NULL")) {
- ownFailed(r.id, account, { provider: r.provider, model: p.plan.model.id, op: p.plan.op, stage: "submit" }, "keys-changed");
- }
+ stopReplanned(r.id, r.provider, account, p, "submit");
+ handOverEnds(r.id);
return true;
}
submitting().add(r.id);
@@@ -3340,6 -3182,48 +3342,22 @@@
return true;
}
+ /**
+ * A run that waited for its own GPU or key, planned again after a restart or a deploy (takeOver, or advanceDependents for
+ * a step of a longer run), that would now go to another provider than the one it waited for: it stops in plain words and
+ * is never sent there, since nobody pressed Run there. `was`: the provider it was made for.
+ */
+ function stopReplanned(id: string, was: string, account: string, p: { plan: { model: { id: string }; op: string } }, stage: "submit" | "chain"): void {
+ const facts: RunFacts = { provider: was, model: p.plan.model.id, op: p.plan.op, stage };
+ if (was === "comfyui") {
+ const gpu = accountGpu(account);
+ const end = diagnoseGpuJob({ kind: gpu ? "moved" : "disconnected" }, { kind: "link", url: gpuLink(gpu)?.url ?? "" });
+ failRun(id, new Error("moved"), end, account, facts);
- } else if (updateIfGoing(id, { status: "failed", error: "This run stopped because your keys changed while it waited. Press Retry.", completed_at: Date.now(), message: null }, " AND external_id IS NULL")) {
++ } else if (updateLive(id, { status: "failed", error: "This run stopped because your keys changed while it waited. Press Retry.", completed_at: Date.now(), message: null }, " AND external_id IS NULL")) {
+ ownFailed(id, account, facts, "keys-changed");
+ }
+ }
+
-declare global {
- /** The renewal of this instance's holds (pointed at the newest code after a hot reload). */
- var __fuobeLeaseRenew: (() => void) | undefined;
-}
-
-/**
- * Renew this instance's holds every LEASE.renewMs. Not one of the runners a stopping server stops (shutdown.ts): a
- * hand-over under way keeps its hold until it lands; a wait hands itself over (pause stops it).
- */
-function keepLeases(): void {
- globalThis.__fuobeLeaseRenew = renewLeases;
- if (globalThis.__fuobeLeaseTimer) return;
- const next = () => {
- globalThis.__fuobeLeaseTimer = setTimeout(() => {
- try {
- globalThis.__fuobeLeaseRenew?.();
- } catch {
- // A busy database: the next renewal comes well before a hold runs out.
- }
- next();
- }, LEASE.renewMs);
- globalThis.__fuobeLeaseTimer.unref?.();
- };
- next();
-}
-
async function pollGuarded(r: Row): Promise<void> {
const polling = (globalThis.__fuobeRunner!.polling ??= new Set());
if (polling.has(r.id)) return;
diff --cc tests/own-gpu-graceful.test.ts
index c1c0e864,aab34b65..1c604035
--- a/tests/own-gpu-graceful.test.ts
+++ b/tests/own-gpu-graceful.test.ts
@@@ -35,8 -35,9 +35,9 @@@ const uploadsRoute = await import("@/ap
const gpuRoute = await import("@/app/api/account/gpu/route");
const generationRoute = await import("@/app/api/generations/[id]/route");
const smallerRoute = await import("@/app/api/generations/[id]/smaller/route");
-const { asAccount, CHAINED_RUN, cancelGeneration, createGenerations, getGeneration, LEASE, OWN_QUEUE, SELF_HEAL, STALE_SUBMIT } = await import("@/server/generations");
+const { asAccount, CHAINED_RUN, cancelGeneration, createGenerations, getGeneration, OWN_QUEUE, QUIET_MS, SELF_HEAL, STALE_SUBMIT } = await import("@/server/generations");
const { ownRunNote } = await import("@/server/run-events");
+ const { removeAccountKey, saveAccountKey } = await import("@/server/account-keys");
const { cleanGpuAddress, checkGpuAddress, visitorStatus } = await import("@/server/account-gpu");
const { comfyProvider, onOwnGpu, queuePlace } = await import("@/server/providers/comfyui");
const { db } = await import("@/server/db");
@@@ -1001,8 -967,58 +1002,56 @@@ describe("a wait survives a restart or
}
});
+ it("so is a step of a longer run that waited: planned for another provider after a restart, it stops, and nothing is sent", async () => {
+ fake.opts.output = "both";
+ const gone = () => ({ by: "gone", until: Date.now() - 1 });
+ const waited = (words: string) => ({ since: Date.now() - 60_000, deadline: Date.now() + 60_000, firstSeen: {}, tries: 3, next: 0, index: 0, words });
+ /** A later step of the run `first` on the account's keys: a still from its frame. */
+ const onKeys = (first: string) => asAccount(a, () => createGenerations({ feature: "image", modelId: "nano-banana-pro", engine: "cloud", prompt: "the same look at night" }, { dependsOn: first }))[0].id;
+ try {
+ const first = await startRun();
+ expect((await settle(first))?.status).toBe("succeeded");
+ // Made for its fal.ai key (it has a Replicate key too), which it waited for on an instance that is gone. Meanwhile
+ // the account removed that key: the next instance would plan it on Replicate, which nobody pressed Run for.
+ saveAccountKey(a, "fal", "acct-fal-graceful");
+ saveAccountKey(a, "replicate", "acct-rep-graceful");
+ const second = onKeys(first);
+ expect(getGeneration(second)?.provider).toBe("fal");
+ setPending(second, { heal: waited("Waiting for fal.ai"), lease: gone() });
+ removeAccountKey(a, "fal");
+ fake.log.length = 0;
+ fetched.length = 0;
+ const g = await settle(second);
+ expect(g?.status).toBe("failed");
+ expect(g?.error).toBe("This run stopped because your keys changed while it waited. Press Retry.");
+ expect(fetched.filter((u) => /fal\.(ai|run|media)|replicate\.com/.test(u))).toEqual([]);
+ expect(getGeneration(second)?.provider).toBe("fal");
+ expect(ownRunNote(second)).toMatchObject({ cause: "keys-changed", stage: "chain" });
+ // One made for its GPU (the row says so), planned on its key now that the account disconnected that GPU: it stops,
+ // saying so, and its key is never used.
+ saveAccountKey(a, "fal", "acct-fal-graceful");
+ const third = onKeys(first);
+ db().prepare("UPDATE generations SET provider = 'comfyui' WHERE id = ?").run(third);
+ setPending(third, { heal: { ...waited("Waiting for your GPU"), firstSeen: { "gpu-off": Date.now() - 60_000 } }, lease: gone() });
+ auth.setAccountGpu(a, null);
+ fake.log.length = 0;
+ fetched.length = 0;
+ const h = await settle(third);
+ expect(h?.status).toBe("failed");
+ expect(h?.error).toBe("You disconnected your GPU, so this run stopped. Connect it again, then press Retry.");
+ expect(h?.trouble?.actions[0]).toMatchObject({ kind: "gpu-settings", label: "Connect your GPU" });
+ expect(fake.log.filter((e) => e.path === "/prompt" || e.path === "/upload/image")).toHaveLength(0);
+ expect(fetched.filter((u) => /fal\.(ai|run|media)|replicate\.com/.test(u))).toEqual([]);
+ expect(ownRunNote(third)).toMatchObject({ cause: "gpu-moved", stage: "chain" });
+ } finally {
+ removeAccountKey(a, "fal");
+ removeAccountKey(a, "replicate");
+ fake.opts.output = undefined;
+ }
+ });
+
it("a deploy's old instance hands its waiting run to the new one, which goes on with it and runs it once", async () => {
SELF_HEAL.scale = 0.01;
- LEASE.ms = 400;
- LEASE.renewMs = 100;
fake.opts.answer = (_m, p) => (p === "/upload/image" || p === "/system_stats" ? html(502) : undefined);
const id = await startRun();
for (let i = 0; i < 500 && !getGeneration(id)?.waiting; i++) await new Promise((r) => setTimeout(r, 10));
diff --cc workflows/comfyui/model-pins.json
index 9f9d9ba2,60cbe6fc..2cb47d18
--- a/workflows/comfyui/model-pins.json
+++ b/workflows/comfyui/model-pins.json
@@@ -1051,14 -918,8 +1051,29 @@@
},
"https://huggingface.co/black-forest-labs/flux-3-image-klein-comfy/resolve/feef60b0aaf63a4773ace96636ebbcf43b881312/text_encoders/qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors": {
"revision": "feef60b0aaf63a4773ace96636ebbcf43b881312",
- "sizeBytes": 6724090780
+ "sizeBytes": 6724090780,
+ "sha256": "e5d85a7421d197bf5a12474511936ecabce19a833252f16e9310a983194a4458"
+ },
+ "https://huggingface.co/briaai/VRMBG-3.0/resolve/59716e19a6cc97f91311edea190938219c097b76/model.safetensors": {
+ "revision": "59716e19a6cc97f91311edea190938219c097b76",
+ "sizeBytes": 884915688,
+ "sha256": "3100fd296d2991f4859db9d83c43ece45f432659b06db3d79810dad033c62253"
+ },
++ "https://huggingface.co/1038lab/FeyNobg/resolve/59dd27c65909b7dcc2de8c3239712b0b997c3e41/FeyNobg.safetensors": {
++ "revision": "59dd27c65909b7dcc2de8c3239712b0b997c3e41",
++ "sizeBytes": 1051353168,
++ "sha256": "7ee181389acf07c6dcf3d72caba2d169224caacdde8bb837ecf7aa3e22e0c3aa"
++ },
++ "https://huggingface.co/1038lab/FeyNobg/resolve/59dd27c65909b7dcc2de8c3239712b0b997c3e41/config.json": {
++ "revision": "59dd27c65909b7dcc2de8c3239712b0b997c3e41",
++ "sizeBytes": 406,
++ "sha256": "1384c6af29d5a54bde9531faac136f02654fea2a38d6bf97fa9fa51949cc6f3a"
++ },
++ "https://huggingface.co/1038lab/FeyNobg/resolve/59dd27c65909b7dcc2de8c3239712b0b997c3e41/preprocessor_config.json": {
++ "revision": "59dd27c65909b7dcc2de8c3239712b0b997c3e41",
++ "sizeBytes": 370,
++ "sha256": "ecd4050a0e22ff56310484c3618f4361fbd63b9c4ccfd941816fa3346c2cff90"
+ },
"https://huggingface.co/city96/Wan2.1-I2V-14B-480P-gguf/resolve/main/wan2.1-i2v-14b-480p-Q8_0.gguf": {
"revision": "b4b6b3b3f0f64975fb33b1d5d1a46ca24e065f03",
"sizeBytes": 18144640384,