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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Evaluation harness: say which LoRAs ComfyUI doesn't have before an open run
Claude6f9b8df92b7c
diff --git a/scripts/eval/eval.mjs b/scripts/eval/eval.mjsindex f805d50a..d4a805c1 100644--- a/scripts/eval/eval.mjs+++ b/scripts/eval/eval.mjs@@ -218,6 +218,7 @@ async function run(args, ctx) {ctx.print(`${result.total} jobs · ${result.runnable} can run · ${result.skipped} skipped · ${result.cases} cases · estimated ${free ? "Free" : money(result.estimateUsd)}${result.unknownCost ? ` (+${result.unknownCost} without a price)` : ""}${engine === "cloud" ? ` · cap ${money(result.maxUsd)}` : ""}`);if (result.models.length) ctx.print(`Models: ${result.models.join(", ")} · variants: ${result.variants.join(", ")}`);for (const [why, n] of Object.entries(result.skipReasons).sort((a, b) => b[1] - a[1]).slice(0, 8)) ctx.print(` ${n} skipped: ${why}`);+ if (result.missingLoras?.length) ctx.print(`LoRAs ComfyUI doesn't have yet (${result.missingLoras.length}): ${result.missingLoras.map((l) => `${l.file} (${l.jobs} job${l.jobs === 1 ? "" : "s"})`).join(", ")}`);if (v.list) for (const j of result.jobs) ctx.print(` ${j.skip ? "·" : "▸"} ${j.case} · ${j.variant} · ${j.prompt} · s${j.seed} · ${j.model}${j.skip ? "" : ` · ${j.costUsd == null ? "price unknown" : free ? "Free" : money(j.costUsd)}`}${j.loras?.applied ? ` · ${j.loras.applied.join(" + ") || "no LoRAs"}` : ""}${j.skip ? ` — ${j.skip}` : ""}`);return 0;}diff --git a/scripts/eval/lib/comfy.mjs b/scripts/eval/lib/comfy.mjsindex 43a97dc0..ebddcb00 100644--- a/scripts/eval/lib/comfy.mjs+++ b/scripts/eval/lib/comfy.mjs@@ -46,6 +46,16 @@ export function comfyProbe(url, opts = {}) {return null;}},+ /** The LoRA files ComfyUI has in models/loras (its LoraLoader's list), or null when it doesn't answer. */+ async loras() {+ try {+ const o = await get("/object_info/LoraLoader", 8000);+ const list = o?.LoraLoader?.input?.required?.lora_name?.[0];+ return Array.isArray(list) ? list : null;+ } catch {+ return null;+ }+ },/** Start sampling (reference-counted, so concurrent jobs share one sampler). */start() {users++;diff --git a/scripts/eval/lib/run.mjs b/scripts/eval/lib/run.mjsindex c68855d9..8ac042ea 100644--- a/scripts/eval/lib/run.mjs+++ b/scripts/eval/lib/run.mjs@@ -37,6 +37,22 @@ const gitCommit = () => {}};+/** The LoRA files the jobs load that aren't in ComfyUI's list (null list: ComfyUI didn't answer, so nothing to say). */+export function lorasMissing(jobs, installed) {+ if (!installed) return null;+ const have = new Set(installed);+ const missing = new Map();+ for (const j of jobs) {+ for (const l of j.preview?.loras?.applied ?? j.request?.loras ?? []) {+ if (!l.file || have.has(l.file)) continue;+ const m = missing.get(l.file) ?? { file: l.file, ...(l.url && { url: l.url }), jobs: 0 };+ m.jobs++;+ missing.set(l.file, m);+ }+ }+ return [...missing.values()];+}+/** Run `fn` over `items` with at most `n` at a time, in order of start. */async function pool(items, n, fn) {let next = 0;@@ -150,17 +166,22 @@ export async function runEval(opts, io) {const estimate = sum(priced.map((j) => j.preview.costUsd));const unknownCost = priced.filter((j) => j.preview.costUsd == null).length;+ // On the open engine: which of the LoRAs the jobs load ComfyUI doesn't have yet (they are never committed;+ // the server downloads pinned copies where it can, else they go in ComfyUI's models/loras by hand).+ const comfy = engine === "open" && opts.comfyUrl ? comfyProbe(opts.comfyUrl, { fetch: io.fetch }) : null;+ const missingLoras = comfy ? lorasMissing(priced, await comfy.loras()) : null;+ if (missingLoras?.length && !opts.dryRun) log(`ComfyUI doesn't have ${missingLoras.length} of the LoRAs these jobs load yet (${missingLoras.slice(0, 3).map((l) => l.file).join(", ")}${missingLoras.length > 3 ? "…" : ""}): jobs fail unless the server fetches them first or you put them in ComfyUI's models/loras.`);+if (opts.dryRun) {const final = planSummary(jobs);const { jobs: total, ...counts } = final;- return { dryRun: true, suite: suite.suite, engine, server: io.target?.url ?? client.url, total, ...counts, estimateUsd: estimate, unknownCost, maxUsd: Number.isFinite(maxUsd) ? maxUsd : null, jobs: jobs.map(publicJob) };+ return { dryRun: true, suite: suite.suite, engine, server: io.target?.url ?? client.url, total, ...counts, estimateUsd: estimate, unknownCost, maxUsd: Number.isFinite(maxUsd) ? maxUsd : null, ...(missingLoras && { missingLoras }), jobs: jobs.map(publicJob) };}if (engine === "cloud" && estimate > maxUsd) {throw new Error(`This run would cost about ${money(estimate)}, over the spend cap of ${money(maxUsd)}. Raise it with --max-usd ${Math.ceil(estimate)} or run fewer jobs (--looks, --cases, --limit, --prompts).`);}// The run's record: what ran, where, with which research files, before anything starts.- const comfy = engine === "open" && opts.comfyUrl ? comfyProbe(opts.comfyUrl, { fetch: io.fetch }) : null;const comfyInfo = comfy ? await comfy.info() : null;const run = {runId,@@ -171,7 +192,7 @@ export async function runEval(opts, io) {engine,label: opts.label ?? previous?.label ?? null,server: { url: io.target?.url ?? client.url, engineMode: facts.engineMode, demoMode: facts.demoMode, cloudProvider: facts.cloudProvider, providers: facts.providers },- comfy: comfy ? { url: comfy.url, ...(comfyInfo ?? { unreachable: true }) } : null,+ comfy: comfy ? { url: comfy.url, ...(comfyInfo ?? { unreachable: true }), ...(missingLoras?.length && { missingLoras }) } : null,filters,variants: summary.variants,variantInfo: Object.fromEntries(summary.variants.map((v) => [v, suite.variants?.[v]?.description ?? ""])),diff --git a/tests/eval-harness.test.ts b/tests/eval-harness.test.tsindex f7525214..91460d1e 100644--- a/tests/eval-harness.test.ts+++ b/tests/eval-harness.test.ts@@ -37,7 +37,10 @@ const genjutsuEstimate = await import("@/app/api/genjutsu/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> };const cases = (await import("../scripts/eval/lib/cases.mjs")) as { loadSuite: (n: string) => Record<string, unknown>; validateAll: () => { ok: boolean; file: string; lines: string[] }[] };-const runner = (await import("../scripts/eval/lib/run.mjs")) as { runEval: (opts: object, io: object) => Promise<Record<string, unknown>> };+const runner = (await import("../scripts/eval/lib/run.mjs")) as {+ runEval: (opts: object, io: object) => Promise<Record<string, unknown>>;+ lorasMissing: (jobs: object[], installed: string[] | null) => { file: string; url?: string; jobs: number }[] | null;+};const report = (await import("../scripts/eval/lib/report.mjs")) as { writeReport: (dir: string, root: string) => Record<string, unknown> };const review = (await import("../scripts/eval/lib/review.mjs")) as {writeReview: (run: object, opts?: object) => { pairs: number };@@ -456,6 +459,17 @@ describe("report, blind review, compare and promote", () => {});describe("runEval as a library", () => {+ it("names the LoRAs ComfyUI doesn't have yet, once each with how many jobs load them", () => {+ const job = (files: string[], applied = true) => (applied ? { preview: { loras: { applied: files.map((file) => ({ file, url: `https://x/${file}` })) } } } : { request: { loras: files.map((file) => ({ file })) } });+ const jobs = [job(["a.safetensors", "b.safetensors"]), job(["a.safetensors"]), job(["[ZImage.Turbo]c.safetensors"], false)];+ expect(runner.lorasMissing(jobs, ["b.safetensors"])).toEqual([+ { file: "a.safetensors", url: "https://x/a.safetensors", jobs: 2 },+ { file: "[ZImage.Turbo]c.safetensors", jobs: 1 },+ ]);+ // ComfyUI didn't answer: nothing to say.+ expect(runner.lorasMissing(jobs, null)).toBeNull();+ });+it("expands, prices and lists a dry run without uploading anything", async () => {const before = seen.filter((s) => s === "POST /api/uploads").length;const suite = cases.loadSuite("dop");