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.

Chain steps on the cloud don't wait for ComfyUI

Claudeec0d6138a16e
diff --git a/src/server/generations.ts b/src/server/generations.ts
index ada24794..6ca27c56 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -967,9 +967,11 @@ async function advanceDependents(): Promise<void> {
fail(`${earlier} has no ${slotNoun(slots[missing])} to use`);
continue;
}
- // Routing reads cached reachability: make sure it's fresh for local engines.
+ // Routing reads cached reachability: make sure it's fresh for local engines. An Original counts with the routes of
+ // the engine it runs on, ComfyUI taken as answering: one on the cloud doesn't use it, so doesn't wait for it.
const model = getModel(request.modelId);
- if (model?.routes.some((x) => x.provider === "comfyui") && !(await probeComfy()) && deps.some((d) => d!.provider === "comfyui")) {
+ const runs = model && dualEngine(model) ? onEngine(model, pickEngine(model, request.engine, engineMode(), () => true)) : model;
+ if (runs?.routes.some((x) => x.provider === "comfyui") && !(await probeComfy()) && deps.some((d) => d!.provider === "comfyui")) {
// The earlier steps ran for real on ComfyUI: one missed check (a server busy finishing them, or restarting)
// mustn't make this one a demo, which chainMode fails. Look again at once (one forced look a sweep), then wait
// for the next sweeps (COMFY_WAIT from the first miss) before chainMode has its say.
diff --git a/tests/comfy-reach.test.ts b/tests/comfy-reach.test.ts
index 3640191a..3594a357 100644
--- a/tests/comfy-reach.test.ts
+++ b/tests/comfy-reach.test.ts
@@ -178,20 +178,23 @@ describe("ComfyUI reachability under load", () => {
});
describe("a chain step after real ComfyUI steps", () => {
- const clip = () => saveFile({ data: Buffer.from("not really a video"), contentType: "video/mp4", source: "generation" }).url;
- /** Two clips that ran on ComfyUI, and the join waiting for them. */
- const join = () => {
- const ids = ["a", "b"].map((k) => `comfy-clip-${k}-${Math.random().toString(36).slice(2, 8)}`);
- for (const id of ids) {
- db()
- .prepare(
- `INSERT INTO generations (id, feature, model_id, engine, provider, op, kind, status, request_json, outputs_json, external_id, created_at, updated_at, completed_at)
- VALUES (?, 'canvas', 'oss-fit-clip', 'open', 'comfyui', 'video-fit', 'video', 'succeeded', '{"feature":"canvas","modelId":"oss-fit-clip"}', ?, 'x', ?, ?, ?)`,
- )
- .run(id, JSON.stringify([{ url: clip(), kind: "video", contentType: "video/mp4" }]), Date.now(), Date.now(), Date.now());
- }
- return gens.createGenerations({ feature: "canvas", modelId: "oss-join-encoded", op: "concat", chain: [{ slot: "videos" }, { slot: "videos" }] }, { dependsOn: ids })[0];
+ /** A step that ran for real on ComfyUI: a clip (oss-fit-clip), or a still (oss-z-image-turbo). */
+ const ranOnComfy = (kind: "video" | "image" = "video") => {
+ const id = `comfy-${kind}-${Math.random().toString(36).slice(2, 8)}`;
+ const contentType = kind === "video" ? "video/mp4" : "image/png";
+ const file = saveFile({ data: Buffer.from(`not really a ${kind}`), contentType, source: "generation" }).url;
+ const [model, op] = kind === "video" ? ["oss-fit-clip", "video-fit"] : ["oss-z-image-turbo", "text-to-image"];
+ db()
+ .prepare(
+ `INSERT INTO generations (id, feature, model_id, engine, provider, op, kind, status, request_json, outputs_json, external_id, created_at, updated_at, completed_at)
+ VALUES (?, 'canvas', ?, 'open', 'comfyui', ?, ?, 'succeeded', ?, ?, 'x', ?, ?, ?)`,
+ )
+ .run(id, model, op, kind, JSON.stringify({ feature: "canvas", modelId: model }), JSON.stringify([{ url: file, kind, contentType }]), Date.now(), Date.now(), Date.now());
+ return id;
};
+ /** Two clips that ran on ComfyUI, and the join waiting for them. */
+ const join = () =>
+ gens.createGenerations({ feature: "canvas", modelId: "oss-join-encoded", op: "concat", chain: [{ slot: "videos" }, { slot: "videos" }] }, { dependsOn: [ranOnComfy(), ranOnComfy()] })[0];
/** A missed check, as a busy server that didn't answer in time left it. */
const missed = () => (globalThis.__fuobeComfyReach = { ok: false, at: Date.now(), url: comfyUrl });
const launched = (id: string) => until(() => {
@@ -226,6 +229,21 @@ describe("a chain step after real ComfyUI steps", () => {
expect(done.error ?? "").not.toMatch(/needs ComfyUI to continue/);
});
+ it("doesn't wait for ComfyUI when the step runs on the cloud (an Original on its cloud engine)", async () => {
+ status = 503;
+ missed();
+ const g = gens.createGenerations(
+ { feature: "canvas", modelId: "fuobe-dop", engine: "cloud", prompt: "A slow push in", chain: [{ slot: "images" }] },
+ { dependsOn: ranOnComfy("image") },
+ )[0];
+ // No cloud key here: it's settled at once, as before, by chainMode naming the cloud provider (not by a minute's wait).
+ const done: Generation = await until(() => {
+ const x = gens.getGeneration(g.id)!;
+ return x.status === "failed" ? x : undefined;
+ }, 15_000);
+ expect(done.error).toMatch(/Fuobe DoP needs (fal\.ai|Replicate) to continue/);
+ });
+
it("fails as before once the wait is over and ComfyUI still doesn't answer", async () => {
const wait = gens.COMFY_WAIT.ms;
gens.COMFY_WAIT.ms = 1000;