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.

Photo runs: retrying a chained step that never launched waits for its finished steps again

Claudee97a39e43bf6
diff --git a/src/server/photodump.ts b/src/server/photodump.ts
index 7ead545d..79d2f59f 100644
--- a/src/server/photodump.ts
+++ b/src/server/photodump.ts
@@ -21,7 +21,7 @@ import type { Engine, Generation, GenerationRequest } from "@/lib/catalog/types"
import { createPipeline } from "./chains";
import { db } from "./db";
import { getElement } from "./elements";
-import { createGenerations, getGeneration, previewGeneration } from "./generations";
+import { createGenerations, getGeneration, pickOutput, previewGeneration } from "./generations";
import { trashGenerations } from "./library";
import { higgsfieldKey } from "./providers/higgsfield";
import { engineMode } from "./settings";
@@ -163,6 +163,21 @@ function dependsOn(id: string): string[] {
return dep ? (dep.startsWith("[") ? (JSON.parse(dep) as string[]) : [dep]) : [];
}
+/**
+ * Whether a chained step got its earlier steps' outputs: the runner writes them into its request when it
+ * launches it, so a step that failed or was canceled while it waited still has only its own inputs.
+ * (A text dependency fills the prompt instead and counts as given.)
+ */
+function gotChainInputs(g: Generation, before: Generation[]): boolean {
+ const given = new Set(Object.values(g.request.inputs ?? {}).flat());
+ return before.every((d, i) => {
+ const slot = g.request.chain?.[i] ?? { slot: "images" as const };
+ if (slot.slot === "prompt") return true;
+ const url = pickOutput(d.outputs, slot)?.url;
+ return !!url && given.has(url);
+ });
+}
+
/** The features whose photos can be retried from their run's grid (Photodump, Fashion Factory, Character Sheet). */
const RETRY_FEATURES = new Set(["photodump", "fashion", "character-sheet", "app:app-ai-influencer", "influencer"]);
@@ -194,6 +209,13 @@ export function retryPhoto(id: string): Generation[] {
trashGenerations([step.id, id]);
return items;
}
+ // Its earlier steps finished, but it never launched (it failed or was canceled while it waited): it waits
+ // for them again, so the runner hands it their outputs (the sheet goes in as image 1) and launches it.
+ if (deps.length && !gotChainInputs(g, before as Generation[])) {
+ const items = createGenerations(fitted(g.request), { ...(g.batchId && { batchId: g.batchId }), dependsOn: deps });
+ trashGenerations([id]);
+ return items;
+ }
const req = fitted(g.request);
const p = previewGeneration(req);
const per = p.jobs > 1 ? Math.max(1, Math.round(p.outputs / p.jobs)) : undefined;
diff --git a/tests/influencer-api.test.ts b/tests/influencer-api.test.ts
index b43999a3..93988723 100644
--- a/tests/influencer-api.test.ts
+++ b/tests/influencer-api.test.ts
@@ -10,6 +10,7 @@ delete process.env.HF_KEY;
delete process.env.HF_API_KEY;
const { setSetting } = await import("@/server/settings");
+const { db } = await import("@/server/db");
const gens = await import("@/server/generations");
const { saveFile } = await import("@/server/storage");
const route = await import("@/app/api/influencer/route");
@@ -104,6 +105,29 @@ describe("/api/influencer", () => {
expect(retryPhoto(one.items[0].id)[0]).toMatchObject({ feature: "influencer", batchId: one.items[0].batchId });
}, 60_000);
+ it("retries a face pass that never launched with the sheet chained in again (canceled while it waited)", async () => {
+ const face = upload();
+ const run = await (await post({ engine: "open", state, start: "face", photo: face })).json();
+ const [sheet, pass] = run.items as { id: string }[];
+ await gens.cancelGeneration(pass.id);
+ expect((await settle(sheet.id)).status).toBe("succeeded");
+ const sheetUrl = gens.getGeneration(sheet.id)!.outputs[0].url;
+ expect(gens.getGeneration(pass.id)!.request.inputs?.images).toEqual([face]);
+ // Only the pass runs again: it waits for the finished sheet, then gets it as image 1.
+ const again = retryPhoto(pass.id);
+ expect(again.map((g) => [g.feature, g.modelId, g.batchId])).toEqual([["influencer", "oss-qwen-edit", run.batchId]]);
+ expect(gens.getGeneration(pass.id)).toBeNull();
+ const redone = await settle(again[0].id);
+ expect(redone.status).toBe("succeeded");
+ expect(redone.request.inputs?.images).toEqual([sheetUrl, face]);
+ // A pass that launched (the sheet is in its request) and then failed is retried as it was: no second sheet.
+ db().prepare("UPDATE generations SET status = 'failed' WHERE id = ?").run(redone.id);
+ const once = retryPhoto(redone.id);
+ expect(once).toHaveLength(1);
+ expect(db().prepare("SELECT depends_on FROM generations WHERE id = ?").get(once[0].id)).toEqual({ depends_on: null });
+ expect((await settle(once[0].id)).request.inputs?.images).toEqual([sheetUrl, face]);
+ }, 60_000);
+
it("follows the engine mode", async () => {
setSetting("engineMode", "open");
const run = await (await post({ engine: "cloud", state, start: "scratch" })).json();