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.

Originals O13: the evolution eval suite runs in demo mode, and eval validate refuses a body that names an input a case doesn't have

Claudeb2a2d96345ec
diff --git a/scripts/eval/cases/evolution.json b/scripts/eval/cases/evolution.json
index 67dc1b2d..fd1c8bed 100644
--- a/scripts/eval/cases/evolution.json
+++ b/scripts/eval/cases/evolution.json
@@ -54,7 +54,8 @@
"demoInputs": {
"video": "fixtures/walk-6s.mp4",
"images": [
- "fixtures/references/warm-1.png"
+ "fixtures/references/warm-1.png",
+ "fixtures/references/warm-2.png"
]
},
"prompts": [
@@ -97,7 +98,8 @@
"demoInputs": {
"video": "fixtures/walk-6s.mp4",
"images": [
- "fixtures/references/warm-1.png"
+ "fixtures/references/warm-1.png",
+ "fixtures/references/warm-2.png"
]
},
"prompts": [
@@ -140,7 +142,8 @@
"demoInputs": {
"video": "fixtures/walk-6s.mp4",
"images": [
- "fixtures/references/warm-1.png"
+ "fixtures/references/warm-1.png",
+ "fixtures/references/warm-2.png"
]
},
"prompts": [
@@ -184,7 +187,9 @@
"demoInputs": {
"video": "fixtures/walk-6s.mp4",
"images": [
- "fixtures/references/warm-1.png"
+ "fixtures/references/warm-1.png",
+ "fixtures/references/warm-2.png",
+ "fixtures/palette.png"
]
},
"prompts": [
diff --git a/scripts/eval/lib/schema.mjs b/scripts/eval/lib/schema.mjs
index 73d7bc8d..0daf6f66 100644
--- a/scripts/eval/lib/schema.mjs
+++ b/scripts/eval/lib/schema.mjs
@@ -248,6 +248,17 @@ export const SuiteSchema = z
for (const v of Object.keys(c.variantModels ?? {})) {
if (!s.variants?.[v]) ctx.addIssue({ code: "custom", path: ["cases", i, "variantModels", v], message: `no variant ${v} in this suite` });
}
+ // Every input a route body names is in the case's inputs and its demo inputs (fillTemplate refuses a missing one).
+ for (const t of bodyTokens(c.submit?.body)) {
+ const m = /^(?:source:)?inputs\.(\w+)(?:\.(\d+))?$/.exec(t);
+ if (!m) continue;
+ for (const key of ["inputs", "demoInputs"]) {
+ if (!c[key]) continue;
+ const v = c[key][m[1]];
+ const has = m[2] === undefined ? v !== undefined : Array.isArray(v) && v.length > Number(m[2]);
+ if (!has) ctx.addIssue({ code: "custom", path: ["cases", i, key], message: `the route body names {{${t}}}, which ${key} doesn't have` });
+ }
+ }
});
const variants = Object.keys(s.variants ?? { default: {} });
for (const k of ["variant", "candidate"]) {
@@ -255,6 +266,14 @@ export const SuiteSchema = z
}
});
+/** The {{tokens}} a route body template names (scripts/eval/lib/media.mjs fillTemplate). */
+function bodyTokens(v, out = []) {
+ if (typeof v === "string") for (const m of v.matchAll(/\{\{\s*([\w.:-]+)\s*\}\}/g)) out.push(m[1]);
+ else if (Array.isArray(v)) for (const x of v) bodyTokens(x, out);
+ else if (v && typeof v === "object") for (const x of Object.values(v)) bodyTokens(x, out);
+ return out;
+}
+
/** Readable lines for a failed parse: `cases[3].prompts[0].seed: expected an integer`. */
export function issues(error) {
return error.issues.map((i) => {
diff --git a/tests/eval-harness.test.ts b/tests/eval-harness.test.ts
index 94825723..79e45301 100644
--- a/tests/eval-harness.test.ts
+++ b/tests/eval-harness.test.ts
@@ -36,6 +36,8 @@ const genjutsu = await import("@/app/api/genjutsu/route");
const genjutsuEstimate = await import("@/app/api/genjutsu/estimate/route");
const mixedEstimate = await import("@/app/api/mixed-media/estimate/route");
const paletteLock = await import("@/app/api/palettes/lock/route");
+const evolution = await import("@/app/api/evolution/route");
+const evolutionEstimate = await import("@/app/api/evolution/estimate/route");
// The harness is plain ESM JavaScript (it runs with node, no build step).
const evalCli = (await import("../scripts/eval/eval.mjs")) as { main: (argv: string[], io?: object) => Promise<number> };
@@ -72,6 +74,8 @@ const ROUTES: [string, RegExp, (req: Request, m: RegExpExecArray) => Promise<Res
["POST", /^\/api\/genjutsu\/estimate$/, (r) => genjutsuEstimate.POST(r)],
["POST", /^\/api\/mixed-media\/estimate$/, (r) => mixedEstimate.POST(r)],
["POST", /^\/api\/palettes\/lock$/, (r) => paletteLock.POST(r)],
+ ["POST", /^\/api\/evolution$/, (r) => evolution.POST(r)],
+ ["POST", /^\/api\/evolution\/estimate$/, (r) => evolutionEstimate.POST(r)],
];
let server: http.Server;
@@ -157,6 +161,26 @@ describe("case files", () => {
expect(message).toMatch(/duplicate case id a/);
expect(message).toMatch(/a look needs "recipe": "soul-look"/);
});
+
+ it("refuses a route body that names an input the case's inputs or demo inputs don't have", () => {
+ const bad = path.join(dir, "bad-inputs.json");
+ const kase = (demo: string[]) => ({
+ id: `x/${demo.length}`,
+ title: "x",
+ inputs: { images: ["local/x/a.png", "local/x/b.png"] },
+ demoInputs: { images: demo },
+ submit: { route: "/api/x", body: { refs: ["{{inputs.images.0}}", "{{inputs.images.1}}"], video: "{{source:inputs.video}}" } },
+ });
+ fs.writeFileSync(bad, JSON.stringify({ suite: "bad-inputs", title: "x", description: "x", original: "x", kind: "video", targets: { demo: { models: ["x"] } }, cases: [kase(["fixtures/a.png"])] }));
+ let message = "";
+ try {
+ cases.loadSuite(bad);
+ } catch (e) {
+ message = (e as Error).message;
+ }
+ expect(message).toMatch(/cases\[0\]\.demoInputs: the route body names \{\{inputs\.images\.1\}\}, which demoInputs doesn't have/);
+ expect(message).toMatch(/cases\[0\]\.inputs: the route body names \{\{source:inputs\.video\}\}, which inputs doesn't have/);
+ });
});
describe("the runner on the demo provider", () => {
@@ -237,6 +261,22 @@ describe("the runner on the demo provider", () => {
expect(row.outputs?.[0]?.kind).toBe("video");
});
+ it("runs Fuobe Evolution's suite on the demo provider: two references a case, three for the written direction", async () => {
+ const r = await cli(["run", "--suite", "evolution", "--engine", "demo", "--cases", "evolution/low,evolution/written", "--no-metrics"]);
+ expect(r.code, r.stderr).toBe(0);
+ const rows = store.latestJobs(path.join(results, runIdFrom(r.stderr)));
+ expect(rows.map((x) => [x.caseId, x.status]).sort()).toEqual([
+ ["evolution/low", "succeeded"],
+ ["evolution/written", "succeeded"],
+ ]);
+ const body = (id: string) => (rows.find((x) => x.caseId === id)!.request as { body: Record<string, unknown> }).body;
+ expect(body("evolution/low")).toMatchObject({ engine: "open", intensity: "low" });
+ expect(body("evolution/low").references).toHaveLength(2);
+ expect(body("evolution/written").references).toHaveLength(3);
+ expect(body("evolution/written").direction).toBeUndefined();
+ expect(rows.every((x) => x.outputs?.[0]?.kind === "video")).toBe(true);
+ });
+
it("runs Genjutsu's Character swap on the 6 s fixture clip: the part, the character, who to swap", async () => {
const r = await cli(["run", "--suite", "genjutsu", "--engine", "demo", "--cases", "genjutsu/character,genjutsu/character-plain", "--no-metrics"]);
expect(r.code, r.stderr).toBe(0);