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
Tests: zip checks read archives in Node, and tool checks run on Windows too
Adarsh1b1c6c534b83
diff --git a/scripts/eval/metrics/tests/test_media_and_models.py b/scripts/eval/metrics/tests/test_media_and_models.pyindex 451bd718..e6d34db1 100644--- a/scripts/eval/metrics/tests/test_media_and_models.py+++ b/scripts/eval/metrics/tests/test_media_and_models.py@@ -15,6 +15,17 @@ from fuobe_metrics import medianeeds_ffmpeg = pytest.mark.skipif(not media.have_ffmpeg(), reason="ffmpeg isn't installed")+def _svg_decoder() -> bool:+ if not media.have_ffmpeg():+ return False+ out = subprocess.run(["ffmpeg", "-hide_banner", "-decoders"], capture_output=True, text=True).stdout+ return " librsvg " in out+++# Some ffmpeg builds (the common Windows ones) have no SVG decoder.+needs_svg = pytest.mark.skipif(not _svg_decoder(), reason="this ffmpeg has no SVG decoder (librsvg)")++def _clip(tmp_path, name="clip.mp4", seconds=2, size="160x96", audio=True):out = tmp_path / namecmd = ["ffmpeg", "-v", "error", "-y", "-f", "lavfi", "-i", f"testsrc=size={size}:rate=12:duration={seconds}"]@@ -38,7 +49,7 @@ def test_load_image_png():assert img.mode == "RGB" and img.size == (500, 100)-@needs_ffmpeg+@needs_svgdef test_load_image_rasterises_svg(tmp_path):svg = tmp_path / "demo.svg"svg.write_text('<svg xmlns="http://www.w3.org/2000/svg" width="64" height="32"><rect width="64" height="32" fill="#ff0000"/></svg>')diff --git a/tests/cli-run.test.ts b/tests/cli-run.test.tsindex b5787439..fb7d16d0 100644--- a/tests/cli-run.test.ts+++ b/tests/cli-run.test.ts@@ -198,7 +198,7 @@ describe("fuobe CLI against a Fuobe server", () => {const r = await run(["generate", "a red fox", "--image", "me.png", "--aspect", "1:1", "--out", "renders", "--interval", "0.2"]);expect(r.stderr).toContain("Using Nano Banana Pro (nano-banana-pro)");expect(r.code).toBe(0);- expect(r.stdout).toMatch(/^Saved renders\/gen1\.png \(1 KB\)$/m);+ expect(r.stdout).toMatch(/^Saved renders[\\/]gen1\.png \(1 KB\)$/m);expect(fs.readFileSync(path.join(tmp, "renders/gen1.png")).equals(PNG)).toBe(true);// Every request carried the token.expect(seen.every((s) => s.auth === `Bearer ${TOKEN}`)).toBe(true);@@ -361,12 +361,13 @@ describe("fuobe CLI against a Fuobe server", () => {it("saves a download inside --out whatever id the server sends", async () => {const r = await run(["download", "evil", "--out", "safe"]);expect(r.code).toBe(0);- expect(r.stdout).toMatch(/^Saved safe\/___escaped\.png \(1 KB\)$/m);+ expect(r.stdout).toMatch(/^Saved safe[\\/]___escaped\.png \(1 KB\)$/m);expect(fs.existsSync(path.join(tmp, "escaped.png"))).toBe(false);expect(fs.readdirSync(path.join(tmp, "safe"))).toEqual(["___escaped.png"]);});- it("stops waiting at once on Ctrl+C, not after the next --interval", async () => {+ // Windows has no SIGINT to send to another process: kill() ends it at once, with no exit code.+ it.skipIf(process.platform === "win32")("stops waiting at once on Ctrl+C, not after the next --interval", async () => {const t0 = Date.now();let child: ReturnType<typeof spawn> | undefined;const done = run(["wait", "slow", "--interval", "30"], {}, (c) => (child = c));@@ -458,7 +459,7 @@ describe("fuobe skills: a skill that runs by itself", () => {const r = await run(["skills", "run", "weekly-promo", "-p", "product=lamp.png", "-p", "name=Lumen", "--yes", "--out", "promo", "--interval", "0.2"]);expect(r.code).toBe(0);expect(r.stderr).toContain("Pricing /weekly-promo on the cloud first (free: nothing runs)…");- expect(r.stdout).toMatch(/^Saved promo\/gen1\.png \(1 KB\)$/m);+ expect(r.stdout).toMatch(/^Saved promo[\\/]gen1\.png \(1 KB\)$/m);// Priced with a stand-in, checked, then the file went up once and the run used its URL.expect(seen.filter((s) => s.method === "POST").map((s) => s.path)).toEqual(["/api/assist/skills/weekly-promo/estimate",diff --git a/tests/cli.test.ts b/tests/cli.test.tsindex 25e02c7b..98339d25 100644--- a/tests/cli.test.ts+++ b/tests/cli.test.ts@@ -253,8 +253,8 @@ describe("output", () => {describe("config and the server address", () => {it("finds the config file", () => {- expect(configPath({}, "/home/me")).toBe("/home/me/.config/fuobe/config.json");- expect(configPath({ XDG_CONFIG_HOME: "/cfg" }, "/home/me")).toBe("/cfg/fuobe/config.json");+ expect(configPath({}, "/home/me")).toBe(path.join("/home/me", ".config/fuobe/config.json"));+ expect(configPath({ XDG_CONFIG_HOME: "/cfg" }, "/home/me")).toBe(path.join("/cfg", "fuobe/config.json"));expect(configPath({ FUOBE_CONFIG: "/x.json" }, "/home/me")).toBe("/x.json");});@@ -395,7 +395,7 @@ describe("skills add", () => {write("repo/top/SKILL.md", skill("top"));write("repo/node_modules/x/SKILL.md", skill("x"));write("repo/docs/deep/er/SKILL.md", skill("deep"));- const names = findSkillDirs(repo).map((d) => path.relative(repo, d));+ const names = findSkillDirs(repo).map((d) => path.relative(repo, d).split(path.sep).join("/"));expect(names).toEqual([".agents/skills/c", "skills/a", "skills/marketing/b", "top"]);// A folder that is a skill is just that skill.expect(findSkillDirs(path.join(repo, "skills/a"))).toEqual([path.join(repo, "skills/a")]);diff --git a/tests/comfy-install.test.ts b/tests/comfy-install.test.tsindex ca37796c..047d9d3e 100644--- a/tests/comfy-install.test.ts+++ b/tests/comfy-install.test.ts@@ -72,7 +72,7 @@ describe("Workflows → Copy install commands", () => {it("the commands run, and run again, as install-comfyui.sh does: a pinned clone moves to its pin, a copied pack isn't copied twice", () => {const tmp = tempDir("fuobe-comfy-install-");const git = (cwd: string, ...args: string[]) =>- execFileSync("git", ["-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", "-c", "init.defaultBranch=main", ...args], { cwd, encoding: "utf8" }).trim();+ execFileSync("git", ["-c", "user.name=t", "-c", "user.email=t@t", "-c", "commit.gpgsign=false", "-c", "init.defaultBranch=main", "-c", "core.autocrlf=false", ...args], { cwd, encoding: "utf8" }).trim();/** A stand-in remote with two commits; the first is the pin. */const remote = (name: string, file: string) => {const d = path.join(tmp, "remotes", name);@@ -84,7 +84,8 @@ describe("Workflows → Copy install commands", () => {const pin = git(d, "rev-parse", "HEAD");fs.writeFileSync(path.join(d, file), "newer\n");git(d, "commit", "-q", "-am", "newer");- return { dir: d, pin, head: git(d, "rev-parse", "HEAD") };+ // The commands name it unquoted, as they name a URL: forward slashes, which bash and git read on Windows too.+ return { dir: d.split(path.sep).join("/"), pin, head: git(d, "rev-parse", "HEAD") };};try {const relay = remote("relay", "__init__.py");@@ -98,7 +99,10 @@ describe("Workflows → Copy install commands", () => {tool.dir,),].join("\n");- const run = () => execFileSync("bash", ["-c", commands], { env: { ...process.env, COMFYUI: comfy }, stdio: "pipe" });+ // Git for Windows' bash would rewrite the sparse-checkout pattern (/worker_nodes/…) into a Windows path, and a+ // global core.autocrlf would change the files checked out; neither is so on Linux, where these commands run.+ const env = { ...process.env, COMFYUI: comfy, MSYS2_ARG_CONV_EXCL: "/worker_nodes/", GIT_CONFIG_COUNT: "1", GIT_CONFIG_KEY_0: "core.autocrlf", GIT_CONFIG_VALUE_0: "false" };+ const run = () => execFileSync("bash", ["-c", commands], { env, stdio: "pipe" });const pack = path.join(comfy, "custom_nodes", "h3_character_swap");const clone = path.join(comfy, "custom_nodes", "h3-relay");run();diff --git a/tests/helpers/python.ts b/tests/helpers/python.tsnew file mode 100644index 00000000..0b27ac1c--- /dev/null+++ b/tests/helpers/python.ts@@ -0,0 +1,31 @@+import { execFileSync, spawnSync, type ExecFileSyncOptions } from "node:child_process";++/**+ * A Python 3 for tests that run the repo's Python scripts: FUOBE_TEST_PYTHON, else python3, else python, else the+ * Windows launcher (py -3). Each is tried for real, since on Windows python3 and python can be Store stubs that only+ * print an install hint. Null when none runs; tests that need one skip then (CI's runner has python3).+ */+function find(): { cmd: string; args: string[] } | null {+ const tries: [string, string[]][] = [+ ...(process.env.FUOBE_TEST_PYTHON ? [[process.env.FUOBE_TEST_PYTHON, []] as [string, string[]]] : []),+ ["python3", []],+ ["python", []],+ ...(process.platform === "win32" ? [["py", ["-3"]] as [string, string[]]] : []),+ ];+ for (const [cmd, args] of tries) {+ const r = spawnSync(cmd, [...args, "-c", "import sys; assert sys.version_info >= (3, 9)"], { encoding: "utf8", timeout: 20_000 });+ if (r.status === 0) return { cmd, args };+ }+ return null;+}++export const python = find();++/**+ * Runs a Python script (as execFileSync does: throws on a non-zero exit, returns stdout). In UTF-8 mode, so what it+ * prints (→, ×) doesn't fail on a Windows console's code page.+ */+export function runPython(args: string[], options: ExecFileSyncOptions = {}): Buffer {+ if (!python) throw new Error("no Python 3 found");+ return execFileSync(python.cmd, [...python.args, ...args], { ...options, env: { ...(options.env ?? process.env), PYTHONUTF8: "1" }, encoding: "buffer" }) as Buffer;+}diff --git a/tests/helpers/zip-read.ts b/tests/helpers/zip-read.tsnew file mode 100644index 00000000..8c54e831--- /dev/null+++ b/tests/helpers/zip-read.ts@@ -0,0 +1,104 @@+import zlib from "node:zlib";++/**+ * A strict ZIP reader for tests, written apart from the app's zip code so a test of a writer doesn't read its+ * output back with the same assumptions. Like Python's zipfile + testzip(): the end record, the central directory+ * and every local header must agree, stored and deflated entries are unpacked, and each entry's CRC-32 and size+ * must match. Any mismatch throws, naming the entry. ZIP64 end records are followed.+ */+export interface ZipInfo {+ filename: string;+ file_size: number;+ data: Buffer;+}++export interface ZipArchive {+ infolist(): ZipInfo[];+ namelist(): string[];+ read(name: string): Buffer;+}++const EOCD = 0x06054b50;+const EOCD64 = 0x06064b50;+const EOCD64_LOCATOR = 0x07064b50;+const CENTRAL = 0x02014b50;+const LOCAL = 0x04034b50;++export function readZip(buf: Buffer | Uint8Array): ZipArchive {+ const b = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);+ let eocd = -1;+ for (let i = b.length - 22; i >= Math.max(0, b.length - 22 - 0xffff); i--) {+ if (b.readUInt32LE(i) === EOCD && i + 22 + b.readUInt16LE(i + 20) === b.length) {+ eocd = i;+ break;+ }+ }+ if (eocd < 0) throw new Error("not a zip: no end of central directory record");+ let count = b.readUInt16LE(eocd + 10);+ let dirSize = b.readUInt32LE(eocd + 12);+ let dirOffset = b.readUInt32LE(eocd + 16);+ if (b.readUInt16LE(eocd + 8) !== count) throw new Error("multi-disk zip");+ if (eocd >= 20 && b.readUInt32LE(eocd - 20) === EOCD64_LOCATOR) {+ const at = Number(b.readBigUInt64LE(eocd - 20 + 8));+ if (b.readUInt32LE(at) !== EOCD64) throw new Error("bad zip64 end record");+ count = Number(b.readBigUInt64LE(at + 32));+ dirSize = Number(b.readBigUInt64LE(at + 40));+ dirOffset = Number(b.readBigUInt64LE(at + 48));+ }+ const infos: ZipInfo[] = [];+ let p = dirOffset;+ for (let n = 0; n < count; n++) {+ if (b.readUInt32LE(p) !== CENTRAL) throw new Error(`bad central directory entry ${n}`);+ const flags = b.readUInt16LE(p + 8);+ const method = b.readUInt16LE(p + 10);+ const crc = b.readUInt32LE(p + 16);+ let compressed = b.readUInt32LE(p + 20);+ let size = b.readUInt32LE(p + 24);+ const nameLen = b.readUInt16LE(p + 28);+ const extraLen = b.readUInt16LE(p + 30);+ const commentLen = b.readUInt16LE(p + 32);+ let local = b.readUInt32LE(p + 42);+ const filename = b.subarray(p + 46, p + 46 + nameLen).toString(flags & 0x800 ? "utf8" : "latin1");+ // ZIP64 extra field: the 64-bit values, in order, for each 32-bit field that is 0xffffffff.+ const extra = b.subarray(p + 46 + nameLen, p + 46 + nameLen + extraLen);+ for (let e = 0; e + 4 <= extra.length; ) {+ const id = extra.readUInt16LE(e);+ const len = extra.readUInt16LE(e + 2);+ if (id === 0x0001) {+ let q = e + 4;+ const next = () => Number(extra.readBigUInt64LE((q += 8) - 8));+ if (size === 0xffffffff) size = next();+ if (compressed === 0xffffffff) compressed = next();+ if (local === 0xffffffff) local = next();+ }+ e += 4 + len;+ }+ p += 46 + nameLen + extraLen + commentLen;+ if (flags & 0x1) throw new Error(`${filename}: encrypted`);+ if (b.readUInt32LE(local) !== LOCAL) throw new Error(`${filename}: bad local header`);+ const localNameLen = b.readUInt16LE(local + 26);+ const localName = b.subarray(local + 30, local + 30 + localNameLen).toString(flags & 0x800 ? "utf8" : "latin1");+ if (localName !== filename) throw new Error(`${filename}: local header names ${localName}`);+ if (b.readUInt16LE(local + 8) !== method) throw new Error(`${filename}: local header method differs`);+ const start = local + 30 + localNameLen + b.readUInt16LE(local + 28);+ if (start + compressed > dirOffset) throw new Error(`${filename}: data runs into the central directory`);+ const raw = b.subarray(start, start + compressed);+ let data: Buffer;+ if (method === 0) data = Buffer.from(raw);+ else if (method === 8) data = zlib.inflateRawSync(raw);+ else throw new Error(`${filename}: compression method ${method}`);+ if (data.length !== size) throw new Error(`${filename}: ${data.length} bytes, the directory says ${size}`);+ if (zlib.crc32(data) >>> 0 !== crc) throw new Error(`${filename}: bad CRC-32`);+ infos.push({ filename, file_size: size, data });+ }+ if (p !== dirOffset + dirSize) throw new Error("central directory size doesn't match the end record");+ return {+ infolist: () => infos,+ namelist: () => infos.map((i) => i.filename),+ read(name) {+ const hit = infos.find((i) => i.filename === name);+ if (!hit) throw new Error(`no ${name} in the zip`);+ return hit.data;+ },+ };+}diff --git a/tests/layers.test.ts b/tests/layers.test.tsindex 60653856..dac7d66c 100644--- a/tests/layers.test.ts+++ b/tests/layers.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from "node:child_process";import fs from "node:fs";import path from "node:path";import { describe, expect, it } from "vitest";@@ -7,6 +6,7 @@ import { imageLimit } from "@/lib/catalog/plan";import type { Operation } from "@/lib/catalog/types";import { layersHref } from "@/lib/output-actions";import { tempDir } from "./helpers/temp-dir";+import { readZip } from "./helpers/zip-read";import {addNodes,addRevision,@@ -129,9 +129,9 @@ describe("zip naming", () => {try {const file = path.join(dir, "cropped-layers.zip");fs.writeFileSync(file, zip);- const out = execFileSync("python3", ["-c", "import sys,zipfile;z=zipfile.ZipFile(sys.argv[1]);assert z.testzip() is None;print('|'.join(i.filename+':'+str(i.file_size) for i in z.infolist()));print(z.read('layer-z0-background.png').decode())", file]).toString().trim().split("\n");- expect(out[0]).toBe("composite.png:7|layer-z0-background.png:12");- expect(out[1]).toBe("hello layers");+ const z = readZip(fs.readFileSync(file));+ expect(z.infolist().map((i) => `${i.filename}:${i.file_size}`).join("|")).toBe("composite.png:7|layer-z0-background.png:12");+ expect(z.read("layer-z0-background.png").toString()).toBe("hello layers");} finally {fs.rmSync(dir, { recursive: true, force: true });}diff --git a/tests/library.test.ts b/tests/library.test.tsindex 0186cd85..0c1f3b69 100644--- a/tests/library.test.ts+++ b/tests/library.test.ts@@ -1,8 +1,8 @@-import { execFileSync } from "node:child_process";import fs from "node:fs";import path from "node:path";import { beforeAll, describe, expect, it, vi } from "vitest";import { tempDir } from "./helpers/temp-dir";+import { readZip } from "./helpers/zip-read";// Route handlers call connection() (no request scope in a test).vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));@@ -401,8 +401,9 @@ describe("zip download", () => {expect(buf.length).toBe(zipSize(entries));const file = path.join(dir, "out.zip");fs.writeFileSync(file, buf);- const out = execFileSync("python3", ["-I", "-c", "import sys,zipfile;z=zipfile.ZipFile(sys.argv[1]);print(z.testzip(), len(z.namelist()), z.read(z.namelist()[0])[-6:].decode())", file]).toString();- expect(out.trim()).toBe("None 2 zip me");+ const z = readZip(fs.readFileSync(file));+ expect(z.namelist()).toHaveLength(2);+ expect(z.read(z.namelist()[0]).subarray(-6).toString()).toBe("zip me");});});@@ -564,15 +565,15 @@ describe("nested folders", () => {expect(zip.name).toBe("Zip/top");expect(zip.entries.map((e) => e.name.replace(/-[\w-]{6}\.png$/, "")).sort()).toEqual(["Close ups/Hands/zip-deep", "Close ups/zip-sub", "zip-top"]);expect(lib.folderZipEntries("missing")).toBeNull();- // The route: ?check=1 answers the count, then the zip itself reads back in Python.+ // The route: ?check=1 answers the count, then the zip itself reads back.const check = await folderZipRoute.GET(new Request("http://x/zip?check=1"), ctxOf(top.id));expect(await check.json()).toMatchObject({ files: 3 });const res = await folderZipRoute.GET(new Request("http://x/zip"), ctxOf(top.id));expect(res.headers.get("Content-Disposition")).toMatch(/filename="Zip-top-\d{4}-\d{2}-\d{2}\.zip"/);const file = path.join(dir, "folder.zip");fs.writeFileSync(file, Buffer.from(await res.arrayBuffer()));- const names = execFileSync("python3", ["-I", "-c", "import sys,zipfile;z=zipfile.ZipFile(sys.argv[1]);assert z.testzip() is None;print('|'.join(sorted(z.namelist())))", file]).toString().trim();- expect(names.split("|").map((n) => n.replace(/-[\w-]{6}\.png$/, ""))).toEqual(["Close ups/Hands/zip-deep", "Close ups/zip-sub", "zip-top"]);+ const names = readZip(fs.readFileSync(file)).namelist().sort();+ expect(names.map((n) => n.replace(/-[\w-]{6}\.png$/, ""))).toEqual(["Close ups/Hands/zip-deep", "Close ups/zip-sub", "zip-top"]);expect((await folderZipRoute.GET(new Request("http://x/zip"), ctxOf(empty.id))).status).toBe(404);expect((await folderZipRoute.GET(new Request("http://x/zip"), ctxOf("missing"))).status).toBe(404);for (const f of [deeper, sub, top, empty]) lib.deleteFolder(f.id);diff --git a/tests/lora-library.test.ts b/tests/lora-library.test.tsindex 0d05c124..7d604da6 100644--- a/tests/lora-library.test.ts+++ b/tests/lora-library.test.ts@@ -1,10 +1,10 @@-import { execFileSync } from "node:child_process";import fs from "node:fs";import path from "node:path";import { describe, expect, it } from "vitest";import { LORA_LIBRARY, LORA_LIBRARY_AS_OF, MOTION_EFFECT_LORAS } from "@/lib/catalog/lora-library.generated";import { civitaiVersion, libraryEntry, licenceLine, loraByFile, loraEntry, loraRef, needsToken } from "@/lib/catalog/loras";import { tempDir } from "./helpers/temp-dir";+import { python, runPython } from "./helpers/python";const ROOT = path.resolve(__dirname, "..");const DATE = /^\d{4}-\d{2}-\d{2}$/;@@ -124,17 +124,17 @@ describe("LoRA library (lora-library.generated.ts)", () => {expect(loraRef(loraEntry("awportrait")!).strength).toBe(0.6);});- it("is what the generator writes (no hand edits); the generator refuses broken pins and only notes licences", () => {+ it.skipIf(!python)("is what the generator writes (no hand edits); the generator refuses broken pins and only notes licences", () => {const tmp = tempDir("fuobe-lora-gen-");const research = () => JSON.parse(fs.readFileSync(path.join(ROOT, "docs/research/fuobe-originals-recipes-5.json"), "utf8"));const refuses = (data: unknown, why: RegExp) => {fs.writeFileSync(path.join(tmp, "docs/research/fuobe-originals-recipes-5.json"), JSON.stringify(data));- expect(() => execFileSync("python3", [path.join(tmp, "scripts/gen-lora-library.py")], { stdio: "pipe" })).toThrow(why);+ expect(() => runPython([path.join(tmp, "scripts/gen-lora-library.py")], { stdio: "pipe" })).toThrow(why);};// Licences are information (Settings → Models & licences): the generator writes the library and prints a note.const notes = (data: unknown, what: RegExp) => {fs.writeFileSync(path.join(tmp, "docs/research/fuobe-originals-recipes-5.json"), JSON.stringify(data));- expect(execFileSync("python3", [path.join(tmp, "scripts/gen-lora-library.py")], { stdio: "pipe" }).toString()).toMatch(what);+ expect(runPython([path.join(tmp, "scripts/gen-lora-library.py")], { stdio: "pipe" }).toString()).toMatch(what);};try {// A copy of the repo layout the script reads, with one civitai URL unpinned.@@ -143,7 +143,7 @@ describe("LoRA library (lora-library.generated.ts)", () => {fs.mkdirSync(path.join(tmp, "src/lib/catalog"), { recursive: true });fs.copyFileSync(path.join(ROOT, "scripts/gen-lora-library.py"), path.join(tmp, "scripts/gen-lora-library.py"));fs.copyFileSync(path.join(ROOT, "docs/research/fuobe-originals-recipes-5.json"), path.join(tmp, "docs/research/fuobe-originals-recipes-5.json"));- execFileSync("python3", [path.join(tmp, "scripts/gen-lora-library.py")], { stdio: "pipe" });+ runPython([path.join(tmp, "scripts/gen-lora-library.py")], { stdio: "pipe" });expect(fs.readFileSync(path.join(tmp, "src/lib/catalog/lora-library.generated.ts"), "utf8")).toBe(fs.readFileSync(path.join(ROOT, "src/lib/catalog/lora-library.generated.ts"), "utf8"));type Raw = { key?: string; presets?: string[]; status?: string; loras?: Raw[]; url?: string; sha256?: string; revision?: string };// A civitai entry without a pinned version.diff --git a/tests/soul-id-runtime.test.ts b/tests/soul-id-runtime.test.tsindex 321038a5..633705f6 100644--- a/tests/soul-id-runtime.test.ts+++ b/tests/soul-id-runtime.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from "node:child_process";import fs from "node:fs";import path from "node:path";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";@@ -6,6 +5,7 @@ import { onEngine } from "@/lib/catalog/engines";import { getModel } from "@/lib/catalog";import { identityFor, identityKey, SOUL_ID_COPY } from "@/lib/catalog/training";import { tempDir } from "./helpers/temp-dir";+import { readZip } from "./helpers/zip-read";// fal's storage upload goes through its client: the dataset zip and a LoRA sent to fal land here instead.const uploads = vi.hoisted(() => [] as { data: Buffer; type: string; name?: string }[]);@@ -117,7 +117,7 @@ describe("starting a Soul ID training", () => {// The dataset: one caption per photo, named as fal's trainers read them.const zipFile = path.join(dir, "dataset.zip");fs.writeFileSync(zipFile, uploads[0].data);- const names = execFileSync("python3", ["-I", "-c", "import sys,zipfile;print(' '.join(sorted(zipfile.ZipFile(sys.argv[1]).namelist())))", zipFile]).toString().trim().split(" ");+ const names = readZip(fs.readFileSync(zipFile)).namelist().sort();expect(names).toEqual(["001.png", "001.txt", "002.png", "002.txt", "003.png", "003.txt", "004.png", "004.txt", "005.png", "005.txt", "006.png", "006.txt"]);expect(listTrainings(el.id)[0]).toMatchObject({ status: "running", costUsd: 1.7, family: "z-image-turbo", photos: 6 });db().prepare("UPDATE trainings SET status = 'failed' WHERE id = ?").run(t.id);@@ -345,7 +345,7 @@ describe("training anywhere", () => {const kit = await trainingKit(el.id);const file = path.join(dir, kit.name);fs.writeFileSync(file, kit.data);- const names = execFileSync("python3", ["-I", "-c", "import sys,zipfile;print(' '.join(sorted(zipfile.ZipFile(sys.argv[1]).namelist())))", file]).toString().trim().split(" ");+ const names = readZip(fs.readFileSync(file)).namelist().sort();expect(names).toContain("dataset/001.png");expect(names).toContain("dataset/005.txt");expect(names).toContain("README.md");@@ -354,7 +354,8 @@ describe("training anywhere", () => {expect(flux.name).toMatch(/-flux1-dev-training-kit\.zip$/);const fluxFile = path.join(dir, flux.name);fs.writeFileSync(fluxFile, flux.data);- const read = (name: string) => execFileSync("python3", ["-I", "-c", "import sys,zipfile;print(zipfile.ZipFile(sys.argv[1]).read(sys.argv[2]).decode())", fluxFile, name]).toString();+ const fluxZip = readZip(fs.readFileSync(fluxFile));+ const read = (name: string) => fluxZip.read(name).toString();const yaml = names.find((n) => n.endsWith(".yaml"))!;expect(JSON.parse(read(yaml)).config.process[0].model).toMatchObject({ arch: "flux", name_or_path: "black-forest-labs/FLUX.1-dev" });expect(read("README.md")).toMatch(/FLUX\.1 \[dev\] Non-Commercial License · non-commercial weights/);diff --git a/tests/soul-originals.test.ts b/tests/soul-originals.test.tsindex 96490a6f..b6a870e5 100644--- a/tests/soul-originals.test.ts+++ b/tests/soul-originals.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from "node:child_process";import fs from "node:fs";import path from "node:path";import { describe, expect, it } from "vitest";@@ -18,6 +17,7 @@ import { SOUL_CINEMA, SOUL_CORE_LORAS, SOUL_ORIGINALS, SOUL_SAMPLER, SOUL_SIZES,import { applyPreset, FRAGMENT, isNeutral, NEUTRAL, PRESETS, uniforms } from "@/lib/grade";import { finishSteps, outputsToFinish, overlayLayout } from "@/lib/soul-post";import { lookCard, lookSet, SOUL_LOOK_CARDS } from "@/lib/catalog/soul-cards";+import { python, runPython } from "./helpers/python";const ROOT = path.resolve(__dirname, "..");const research = JSON.parse(fs.readFileSync(path.join(ROOT, "docs/research/fuobe-originals-recipes-5.json"), "utf8"));@@ -194,11 +194,11 @@ describe("Soul recipe (soul.ts)", () => {});});-describe("gen-soul-originals.py", () => {+describe.skipIf(!python)("gen-soul-originals.py", () => {it("writes what is committed (the generated files match the research)", () => {const files = ["src/lib/catalog/soul-originals.generated.ts", "src/lib/catalog/soul-looks.generated.ts"].map((f) => path.join(ROOT, f));const before = files.map((f) => fs.readFileSync(f, "utf8"));- execFileSync("python3", ["scripts/gen-soul-originals.py"], { cwd: ROOT });+ runPython(["scripts/gen-soul-originals.py"], { cwd: ROOT });expect(files.map((f) => fs.readFileSync(f, "utf8"))).toEqual(before);});});diff --git a/tests/training-kit.test.ts b/tests/training-kit.test.tsindex 7cbab937..ef8ec310 100644--- a/tests/training-kit.test.ts+++ b/tests/training-kit.test.ts@@ -28,6 +28,8 @@ import {type MotionClip,type TrainingSpec,} from "@/lib/training-kit";+import { readZip } from "./helpers/zip-read";+import { python, runPython } from "./helpers/python";const ROOT = path.resolve(__dirname, "..");/** The parts of an AI-Toolkit process the tests read. */@@ -230,7 +232,7 @@ describe("training kit: the LoRA library's planned entries", () => {expect(getPreset("motion-eyes-in")?.open?.loras).toBeUndefined();});- it("is refused by the generator when a preset uses a planned LoRA or an entry has no licence snapshot; a trained block publishes it", () => {+ it.skipIf(!python)("is refused by the generator when a preset uses a planned LoRA or an entry has no licence snapshot; a trained block publishes it", () => {const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-kit-gen-"));fs.mkdirSync(path.join(tmp, "scripts"));fs.mkdirSync(path.join(tmp, "docs/research"), { recursive: true });@@ -238,7 +240,7 @@ describe("training kit: the LoRA library's planned entries", () => {fs.copyFileSync(path.join(ROOT, "scripts/gen-lora-library.py"), path.join(tmp, "scripts/gen-lora-library.py"));const run = (data: unknown) => {fs.writeFileSync(path.join(tmp, "docs/research/fuobe-originals-recipes-5.json"), JSON.stringify(data));- return execFileSync("python3", [path.join(tmp, "scripts/gen-lora-library.py")], { stdio: "pipe" }).toString();+ return runPython([path.join(tmp, "scripts/gen-lora-library.py")], { stdio: "pipe" }).toString();};try {let data = research();@@ -376,8 +378,7 @@ describe("training kit: the command line", () => {expect(JSON.parse(fs.readFileSync(path.join(out, "fuobe-cctv.aitk.json"), "utf8")).config.process[0].datasets[0].folder_path).toBe(data);expect(fs.existsSync(path.join(out, "fuobe-cctv.fal.json"))).toBe(false);const zip = fs.readFileSync(path.join(out, "fuobe-cctv.dataset.zip"));- const listing = execFileSync("python3", ["-I", "-m", "zipfile", "-l", path.join(out, "fuobe-cctv.dataset.zip")]).toString();- expect(listing.match(/\d{3}\.(jpg|txt)/g)).toHaveLength(80);+ expect(readZip(zip).namelist().filter((n) => /\d{3}\.(jpg|txt)$/.test(n))).toHaveLength(80);// A URL that serves something else is refused; the zip the kit built is taken.served = Buffer.from("another dataset");expect(await runAsync(["job", "fuobe-cctv", "--dataset", data, "--zip-url", zipUrl, "--out", out])).toEqual({ refused: 1, out: expect.stringMatching(/is not fuobe-cctv\.dataset\.zip/) });diff --git a/tests/training.test.ts b/tests/training.test.tsindex 25b29de2..d4c35042 100644--- a/tests/training.test.ts+++ b/tests/training.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from "node:child_process";import fs from "node:fs";import path from "node:path";import { describe, expect, it } from "vitest";@@ -37,6 +36,8 @@ import { buildPayload } from "@/lib/catalog/payload";import { OWN_LOOK, soulPostSteps, soulRecipe } from "@/lib/catalog/soul";import { zip } from "@/server/zip";import { tempDir } from "./helpers/temp-dir";+import { readZip } from "./helpers/zip-read";+import { python, runPython } from "./helpers/python";const ROOT = path.resolve(__dirname, "..");@@ -239,16 +240,17 @@ describe("Fuobe Soul ID targets (build plan O3)", () => {const dir = tempDir("fuobe-zip-");const file = path.join(dir, "kit.zip");fs.writeFileSync(file, zip([{ name: "dataset/001.txt", data: Buffer.from("photo of nvrysfz") }, { name: "a.yaml", data: Buffer.from("{}") }]));- const out = execFileSync("python3", ["-I", "-c", "import sys,zipfile;z=zipfile.ZipFile(sys.argv[1]);print(z.testzip(), z.read('dataset/001.txt').decode())", file]).toString();- expect(out.trim()).toBe("None photo of nvrysfz");+ const z = readZip(fs.readFileSync(file));+ expect(z.namelist()).toEqual(["dataset/001.txt", "a.yaml"]);+ expect(z.read("dataset/001.txt").toString()).toBe("photo of nvrysfz");});});-describe("gen-trainers.py", () => {+describe.skipIf(!python)("gen-trainers.py", () => {it("writes what is committed (the trainers match the research)", () => {const file = path.join(ROOT, "src/lib/catalog/trainers.generated.ts");const before = fs.readFileSync(file, "utf8");- execFileSync("python3", ["scripts/gen-trainers.py"], { cwd: ROOT });+ runPython(["scripts/gen-trainers.py"], { cwd: ROOT });expect(fs.readFileSync(file, "utf8")).toBe(before);});it("records every fal trainer with its licence as data (non-commercial ones too) and where its LoRA comes back", () => {diff --git a/tests/video-finish.test.ts b/tests/video-finish.test.tsindex 8fe7e211..b709d58f 100644--- a/tests/video-finish.test.ts+++ b/tests/video-finish.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from "node:child_process";import fs from "node:fs";import path from "node:path";import { beforeAll, describe, expect, it, vi } from "vitest";@@ -18,6 +17,7 @@ import { editOnlyFormat, outputActions } from "@/lib/output-actions";import { slimModel } from "@/lib/studio-catalog";import { FPS_BOOST_STUDIO, SDR_TO_HDR_STUDIO, UPSCALE_STUDIO, VIDEO_EXPORT_STUDIO, VIDEO_UPSCALE_STUDIO } from "@/lib/studios";import { tempDir } from "./helpers/temp-dir";+import { readZip } from "./helpers/zip-read";// The Upscale hub's video tools (r4/video-finish): FPS Boost and slow motion, SDR to HDR, pro export formats,// the upscalers' options, and chunked open upscaling.@@ -563,8 +563,8 @@ describe("files", () => {}const size = await zipToFile(frames(), dest);expect(fs.statSync(dest).size).toBe(size);- const out = execFileSync("python3", ["-I", "-c", "import sys,zipfile;z=zipfile.ZipFile(sys.argv[1]);print(z.testzip(), '|'.join(f'{i.filename}:{i.file_size}' for i in z.infolist()))", dest]).toString().trim();- expect(out).toBe("None frame_00001.exr:1000|frame_00002.exr:2000|frame_00003.exr:3000");+ const out = readZip(fs.readFileSync(dest)).infolist().map((i) => `${i.filename}:${i.file_size}`).join("|");+ expect(out).toBe("frame_00001.exr:1000|frame_00002.exr:2000|frame_00003.exr:3000");});it("keeps a provider's big EXR zip (streamed to disk, past the 200 MB in-memory cap), or its link when it can't be fetched", async () => {