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.

Training kit: the data check covers the whole folder and the fal zip, and publishing records the real base model and licence

Claude6dc2cf50aa7a
diff --git a/scripts/gen-lora-library.py b/scripts/gen-lora-library.py
index 45354148..1cc075a7 100644
--- a/scripts/gen-lora-library.py
+++ b/scripts/gen-lora-library.py
@@ -18,7 +18,7 @@ a default that uses a non-commercial LoRA, or sends one licensed for the user's
printed as a licence note, never a failure.
Fuobe's own LoRAs (research fuobeTrainedLoras, §6; the training kit in scripts/train/): until a trained file exists
-each one is a "planned" entry (PLANNED_LORAS) that no preset may use. Once scripts/train/publish.mjs has published the
+each one is a "planned" entry (PLANNED_LORAS) that no preset may use. Once `scripts/train/kit.mjs publish` has published the
file and its data-licence log, the entry's `trained` block (pinned URL, SHA256, size, licence) moves it into the library.
Fails (exit 1) when an entry's data is wrong:
@@ -232,7 +232,7 @@ for raw in DATA.get("fuobeTrainedLoras") or []:
group = raw.get("group") or "look"
trained = raw.get("trained")
if trained:
- # Published (scripts/train/publish.mjs): an ordinary library entry, pinned and with its licence snapshot.
+ # Published (scripts/train/kit.mjs publish): an ordinary library entry, pinned and with its licence snapshot.
add(entry({"name": raw.get("name") or key, "base": raw["base"], **trained}, key, group, spare=key not in used))
continue
planned.append({
diff --git a/scripts/train/README.md b/scripts/train/README.md
index 97b5cf61..0a15a89b 100644
--- a/scripts/train/README.md
+++ b/scripts/train/README.md
@@ -64,44 +64,61 @@ node scripts/train/kit.mjs check fuobe-cctv --dataset ~/datasets/fuobe-cctv
```
The check fails when the log has fewer or more files than the spec allows, when an entry is incomplete, when a file is in
-the folder but not in the log (or the other way round), when a file changed after it was logged (its SHA256), or when a
-file has no caption. A job does not start while any of these fails.
+the folder but not in the log (or the other way round), when a file changed after it was logged (its SHA256), when a
+file's caption is missing, empty or without the trigger, or when the folder holds anything else (another kind of file,
+such as a `.mkv` clip or a still in a clip dataset, which the trainer would read too, or a sub-folder). A job does not
+start while any of these fails.
## 2. Make the job
```bash
-node scripts/train/kit.mjs job fuobe-cctv --dataset ~/datasets/fuobe-cctv --zip-url https://…/fuobe-cctv.zip
+node scripts/train/kit.mjs job fuobe-cctv --dataset ~/datasets/fuobe-cctv
+# upload .train/fuobe-cctv/fuobe-cctv.dataset.zip, then:
+node scripts/train/kit.mjs job fuobe-cctv --dataset ~/datasets/fuobe-cctv --zip-url https://…/fuobe-cctv.dataset.zip
```
-This writes two files to `.train/fuobe-cctv/`, which git ignores:
+This writes these files to `.train/fuobe-cctv/`, which git ignores:
- `fuobe-cctv.aitk.json`: the AI-Toolkit job for your own GPU (free). Run it with `python run.py <file>` in an
[ostris/ai-toolkit](https://github.com/ostris/ai-toolkit) checkout. Z-Image Turbo trains with ostris's training
- adapter v2; Z-Image base and Wan 2.2 I2V 14B use AI-Toolkit's own defaults for those models (4-bit Wan with its
+ adapter v2 (every Z-Image spec trains on Turbo here); Z-Image base and Wan 2.2 I2V 14B use AI-Toolkit's own defaults for those models (4-bit Wan with its
accuracy recovery adapter, both experts). Wan 2.2 14B needs a 24 GB card.
-- `fuobe-cctv.fal.json`: the request for the fal trainer, with only the fields that trainer's schema has
- (`trainers.generated.ts`, from the research). Zip the same folder, upload it, and pass its URL as `--zip-url`. fal
- bills per step. `kit.mjs list` shows the price.
+- `fuobe-cctv.dataset.zip`: exactly the checked files (the logged images or clips and their captions), for the fal
+ trainer. Upload it anywhere fal can read and pass its URL as `--zip-url`.
+- `fuobe-cctv.fal.json` (with `--zip-url`): the request for the fal trainer, with only the fields that trainer's schema
+ has (`trainers.generated.ts`, from the research), and the zip's SHA256. The kit downloads the URL first and writes
+ the request only when it is the zip it built, byte for byte. fal bills per step. `kit.mjs list` shows the price.
The kit does not submit anything: that takes a GPU or a fal key, and a person deciding to spend it.
Notes to check on the first run:
- fal's `fal-ai/z-image-trainer` trains on Z-Image base. Whether a base-trained LoRA behaves the same on Z-Image Turbo
- (the model Soul runs on) is unverified, so compare it with the AI-Toolkit Turbo run.
+ (the model Soul runs on) is unverified, so compare it with the AI-Toolkit run, which trains on Turbo.
- fal's Wan 2.2 I2V trainer returns one file. Whether loading it on both experts works as intended is unverified.
## 3. Publish the file
Trained files go to Fuobe's Hugging Face organisation (`fuobe` by default; set `--org` or `FUOBE_HF_ORG` to change it),
-one model repo per LoRA, with the public half of the data-licence log next to the file. The public half says a release
-exists but leaves out its reference.
+one model repo per LoRA, with the public half of the data-licence log next to the file. The public half keeps each
+file's hash, source, licence and date, and says a release exists, but leaves out the release reference, the proof and
+the author (receipts, contracts, call sheets, people's names). A CC0 or public-domain original keeps its public page and
+author as a credit.
```bash
-node scripts/train/kit.mjs publish fuobe-cctv --file output/fuobe-cctv/fuobe-cctv.safetensors # dry run
-HF_TOKEN=… node scripts/train/kit.mjs publish fuobe-cctv --file … --upload --write-research # publish
+node scripts/train/kit.mjs publish fuobe-cctv --file output/fuobe-cctv/fuobe-cctv.safetensors --route ai-toolkit # dry run
+HF_TOKEN=… node scripts/train/kit.mjs publish fuobe-cctv --file … --route ai-toolkit --upload --write-research # publish
pnpm gen:catalog
```
+`--route` says which trainer made the file (`fal` or `ai-toolkit`). The model card's `base_model` is the Hugging Face
+repo that route trained on: `Tongyi-MAI/Z-Image` (fal's `z-image-trainer`), `Tongyi-MAI/Z-Image-Turbo` (fal's Turbo
+trainer, AI-Toolkit's `zimage:turbo`) or `Wan-AI/Wan2.2-I2V-A14B`.
+
+The licence is recorded, not assumed. Data that is all Fuobe's own, CC0 or public domain defaults to Apache-2.0 (the
+base models' licence), outputs may be sold and hosts may run it. With any `licensed` file in the log, say all three:
+`--licence <spdx id or name> --commercial yes|no --hosted-ok yes|no`, as the stock licence allows. Either way the
+snapshot names the data's sources and licences, and that is what Settings → Models & licences shows.
+
A dry run uploads nothing. It prints what would be uploaded and the `trained` block for the research entry. `--upload`
needs a write token and the `hf` command (`pip install huggingface_hub`). It uploads the file, `data-licence-log.json`
and a model card, then reads the commit the upload made. `--write-research` writes the `trained` block into
diff --git a/scripts/train/kit.mjs b/scripts/train/kit.mjs
index 4baf6757..ada9f9ea 100644
--- a/scripts/train/kit.mjs
+++ b/scripts/train/kit.mjs
@@ -6,9 +6,11 @@
* node scripts/train/kit.mjs list every spec, its log and its fal price
* node scripts/train/kit.mjs check <id>|--all [--dataset <dir>] the spec and its data-licence log (against the files)
* node scripts/train/kit.mjs job <id> --dataset <dir> [--zip-url <url>] [--out <dir>]
- * the AI-Toolkit config and the fal request, once the log passes
+ * the AI-Toolkit config, the dataset zip and the fal request,
+ * once the log passes (--zip-url: where that zip was uploaded)
* node scripts/train/kit.mjs motions the motion library's clips and licences
- * node scripts/train/kit.mjs publish <id> --file <lora.safetensors> [--org fuobe] [--upload] [--write-research]
+ * node scripts/train/kit.mjs publish <id> --file <lora.safetensors> --route fal|ai-toolkit [--org fuobe]
+ * [--licence <spdx>] [--commercial yes|no] [--hosted-ok yes|no] [--upload] [--write-research]
*
* See scripts/train/README.md.
*/
@@ -57,22 +59,27 @@ function fail(msg) {
process.exit(1);
}
-/** The dataset folder as the checker sees it: media files with their hashes, and the caption files. */
-function readDataset(dir, media) {
+/**
+ * The dataset folder as the checker sees it: every file but the captions, with its hash (whatever its extension: a
+ * trainer reads more kinds than the spec's media), each caption's text, and anything that is not a plain file.
+ */
+function readDataset(dir) {
if (!dir) return undefined;
if (!fs.existsSync(dir)) fail(`no dataset folder ${dir}`);
- const ext = media === "image" ? /\.(jpe?g|png|webp)$/i : /\.(mp4|mov|webm)$/i;
- const names = fs.readdirSync(dir).sort();
- return {
- files: names.filter((n) => ext.test(n)).map((n) => ({ name: n, sha256: sha256(path.join(dir, n)) })),
- captions: names.filter((n) => n.endsWith(".txt")),
- };
+ const folder = { files: [], captions: {}, other: [] };
+ for (const e of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
+ const p = path.join(dir, e.name);
+ if (!e.isFile()) folder.other.push(e.name);
+ else if (e.name.endsWith(".txt")) folder.captions[e.name] = fs.readFileSync(p, "utf8");
+ else folder.files.push({ name: e.name, sha256: sha256(p) });
+ }
+ return folder;
}
function problemsOf(id, datasetDir) {
const spec = loadSpec(id);
const out = kit.specProblems(spec).map((p) => `spec: ${p}`);
- out.push(...kit.dataLogProblems(loadLog(id), spec, readDataset(datasetDir, spec.media)).map((p) => `data-licence log: ${p}`));
+ out.push(...kit.dataLogProblems(loadLog(id), spec, readDataset(datasetDir)).map((p) => `data-licence log: ${p}`));
return { spec, problems: out };
}
@@ -114,12 +121,28 @@ if (cmd === "list") {
fs.mkdirSync(out, { recursive: true });
const aitk = kit.aiToolkitConfig(spec, path.resolve(dataset), path.join(out, "output"));
fs.writeFileSync(path.join(out, `${id}.aitk.json`), JSON.stringify(aitk, null, 2) + "\n");
+ // The hosted trainer gets exactly the checked files: the logged media and their captions, zipped here.
+ const zipFile = path.join(out, `${id}.dataset.zip`);
+ fs.rmSync(zipFile, { force: true });
+ execFileSync("python3", ["-I", "-m", "zipfile", "-c", zipFile, ...kit.datasetZipNames(loadLog(id))], { cwd: path.resolve(dataset), stdio: "pipe" });
+ const zipSha = sha256(zipFile);
const zip = opt("--zip-url");
- if (zip) fs.writeFileSync(path.join(out, `${id}.fal.json`), JSON.stringify({ endpoint: spec.routes.fal.trainer, input: kit.falTrainingPayload(spec, zip) }, null, 2) + "\n");
+ if (zip) {
+ // The request names a zip only once the uploaded one is this one, byte for byte.
+ const res = await fetch(zip).catch((e) => fail(`could not download ${zip}: ${e.message}`));
+ if (!res.ok) fail(`could not download ${zip}: HTTP ${res.status}`);
+ const got = crypto.createHash("sha256").update(Buffer.from(await res.arrayBuffer())).digest("hex");
+ if (got !== zipSha) fail(`${zip} is not ${path.basename(zipFile)} (SHA256 ${got}, expected ${zipSha}): upload the zip the kit built.`);
+ fs.writeFileSync(path.join(out, `${id}.fal.json`), JSON.stringify({ endpoint: spec.routes.fal.trainer, input: kit.falTrainingPayload(spec, zip), datasetZip: { file: path.basename(zipFile), sha256: zipSha } }, null, 2) + "\n");
+ }
console.log(`${id}: the data-licence log passes.`);
console.log(` Your GPU (free): python run.py ${path.join(out, `${id}.aitk.json`)} (in an ostris/ai-toolkit checkout)`);
- console.log(zip ? ` fal (≈ $${kit.specCostUsd(spec)?.toFixed(2)}): submit ${path.join(out, `${id}.fal.json`)} to ${spec.routes.fal.trainer}` : ` fal: zip the dataset (001.jpg + 001.txt pairs), upload it, and pass --zip-url for the request`);
- console.log(` Not run here. Then: kit.mjs publish ${id} --file <the trained .safetensors>`);
+ console.log(
+ zip
+ ? ` fal (≈ $${kit.specCostUsd(spec)?.toFixed(2)}): submit ${path.join(out, `${id}.fal.json`)} to ${spec.routes.fal.trainer}`
+ : ` fal: upload ${zipFile} (SHA256 ${zipSha}) and run this again with --zip-url <its URL> for the request`,
+ );
+ console.log(` Not run here. Then: kit.mjs publish ${id} --file <the trained .safetensors> --route fal|ai-toolkit`);
} else if (cmd === "motions") {
const research = readJson(RESEARCH);
const row = research.motionsEffects.find((m) => m.status === "motion-library");
@@ -132,7 +155,9 @@ if (cmd === "list") {
} else if (cmd === "publish") {
const id = args[1];
const file = opt("--file");
- if (!id || !file) fail("usage: kit.mjs publish <id> --file <lora.safetensors> [--org fuobe] [--upload] [--write-research]");
+ const route = opt("--route");
+ if (!id || !file || !["fal", "ai-toolkit"].includes(route))
+ fail("usage: kit.mjs publish <id> --file <lora.safetensors> --route fal|ai-toolkit [--org fuobe] [--licence <spdx>] [--commercial yes|no] [--hosted-ok yes|no] [--upload] [--write-research]");
if (!fs.existsSync(file) || !file.endsWith(".safetensors")) fail(`${file} is not a .safetensors file`);
const spec = loadSpec(id);
const log = loadLog(id);
@@ -141,6 +166,18 @@ if (cmd === "list") {
report(id, logProblems.map((p) => `data-licence log: ${p}`));
fail("\nA file is published only with a complete data-licence log.");
}
+ const yesNo = (name) => {
+ const v = opt(name);
+ if (v === undefined) return undefined;
+ if (v !== "yes" && v !== "no") fail(`${name} takes yes or no`);
+ return v === "yes";
+ };
+ const { snapshot, problems: licenceProblems } = kit.trainedLicence(log, { licence: opt("--licence"), commercial: yesNo("--commercial"), hostedOk: yesNo("--hosted-ok") });
+ if (!snapshot) {
+ report(id, licenceProblems.map((p) => `licence: ${p}`));
+ fail("\nThe trained file's licence is recorded, not assumed.");
+ }
+ const baseModel = kit.hfBaseModel(spec, route);
const org = opt("--org") ?? process.env.FUOBE_HF_ORG ?? spec.target.hfRepo.split("/")[0];
const repo = `${org}/${id}`;
const hash = sha256(file);
@@ -150,7 +187,25 @@ if (cmd === "list") {
fs.writeFileSync(path.join(stage, "data-licence-log.json"), JSON.stringify(kit.publicLog(log), null, 2) + "\n");
fs.writeFileSync(
path.join(stage, "README.md"),
- `---\nlicense: apache-2.0\nbase_model: ${spec.base}\ntags: [lora, fuobe]\n---\n\n# ${spec.name}\n\nA LoRA Fuobe trained on its own or licensed data (${log.items.length} ${spec.media === "image" ? "images" : "clips"}). Every file's source, licence and release is in data-licence-log.json.\n\n- Trigger: \`${spec.trigger}\`\n- Strength: ${spec.target.strength}\n- File: ${spec.target.file} (SHA256 ${hash})\n`,
+ [
+ "---",
+ `license: ${snapshot.card.license}`,
+ ...(snapshot.card.licenseName ? [`license_name: ${snapshot.card.licenseName}`] : []),
+ `base_model: ${baseModel}`,
+ "base_model_relation: adapter",
+ "tags: [lora, fuobe]",
+ "---",
+ "",
+ `# ${spec.name}`,
+ "",
+ `A LoRA Fuobe trained on its own or licensed data (${log.items.length} ${spec.media === "image" ? "images" : "clips"}) on ${baseModel}. Every file's source, licence and release is in data-licence-log.json.`,
+ "",
+ `- Trigger: \`${spec.trigger}\``,
+ `- Strength: ${spec.target.strength}`,
+ `- Licence: ${snapshot.licence}; outputs may be sold: ${snapshot.commercial ? "yes" : "no"}; hosts may run it: ${snapshot.hostedOk ? "yes" : "no"}`,
+ `- File: ${spec.target.file} (SHA256 ${hash})`,
+ "",
+ ].join("\n"),
);
const trained = (revision) => ({
file: spec.target.file,
@@ -160,15 +215,15 @@ if (cmd === "list") {
trigger: spec.trigger,
...(spec.target.loraTarget && { target: spec.target.loraTarget }),
download: "direct",
- licence: "Apache-2.0 (Fuobe's own data, data-licence log)",
- commercial: true,
- hostedOk: true,
+ licence: snapshot.licence,
+ commercial: snapshot.commercial,
+ hostedOk: snapshot.hostedOk,
checked: new Date().toISOString().slice(0, 10),
revision,
sha256: hash,
sizeBytes: size,
});
- console.log(`${id} → https://huggingface.co/${repo}\n ${spec.target.file} (${size} bytes, SHA256 ${hash}), data-licence-log.json, README.md\n staged in ${stage}`);
+ console.log(`${id} → https://huggingface.co/${repo} (trained on ${baseModel}, ${route})\n ${spec.target.file} (${size} bytes, SHA256 ${hash}), data-licence-log.json, README.md\n staged in ${stage}`);
if (!flag("--upload")) {
console.log(`\nDry run: nothing uploaded. Add --upload (with HF_TOKEN set and the hf command installed) to publish.`);
console.log(`The research entry's trained block will be:\n${JSON.stringify(trained("<the commit the upload makes>"), null, 1)}`);
@@ -192,5 +247,5 @@ if (cmd === "list") {
console.log(`Wrote the trained block to docs/research/fuobe-originals-recipes-5.json. Now run: pnpm gen:catalog`);
} else console.log(`Add this as fuobeTrainedLoras[${id}].trained in the research, then run pnpm gen:catalog:\n${JSON.stringify(block, null, 1)}`);
} else {
- fail("usage: kit.mjs list | check <id>|--all [--dataset <dir>] | job <id> --dataset <dir> [--zip-url <url>] [--out <dir>] | motions | publish <id> --file <f> [--upload] [--write-research]");
+ fail("usage: kit.mjs list | check <id>|--all [--dataset <dir>] | job <id> --dataset <dir> [--zip-url <url>] [--out <dir>] | motions | publish <id> --file <f> --route fal|ai-toolkit [--upload] [--write-research]");
}
diff --git a/scripts/train/specs/fuobe-frutiger-aero.json b/scripts/train/specs/fuobe-frutiger-aero.json
index c221cfcb..b03fa54d 100644
--- a/scripts/train/specs/fuobe-frutiger-aero.json
+++ b/scripts/train/specs/fuobe-frutiger-aero.json
@@ -31,7 +31,7 @@
}
},
"aiToolkit": {
- "arch": "zimage"
+ "arch": "zimage:turbo"
}
},
"target": {
@@ -39,5 +39,5 @@
"strength": 0.8,
"hfRepo": "fuobe/fuobe-frutiger-aero"
},
- "notes": "fal trains on Z-Image base: whether a base-trained LoRA behaves the same on Z-Image Turbo (Soul's model) is unverified; compare it with the AI-Toolkit Turbo run on the first evaluation."
+ "notes": "fal trains on Z-Image base: whether a base-trained LoRA behaves the same on Z-Image Turbo (Soul's model) is unverified; AI-Toolkit trains on Turbo with the training adapter, so the first evaluation compares the two routes' files on Soul."
}
diff --git a/scripts/train/specs/fuobe-paper-collage.json b/scripts/train/specs/fuobe-paper-collage.json
index fa60a668..55c680d1 100644
--- a/scripts/train/specs/fuobe-paper-collage.json
+++ b/scripts/train/specs/fuobe-paper-collage.json
@@ -32,7 +32,7 @@
}
},
"aiToolkit": {
- "arch": "zimage"
+ "arch": "zimage:turbo"
}
},
"target": {
@@ -40,5 +40,5 @@
"strength": 0.8,
"hfRepo": "fuobe/fuobe-paper-collage"
},
- "notes": "fal trains on Z-Image base: whether a base-trained LoRA behaves the same on Z-Image Turbo (Soul's model) is unverified; compare it with the AI-Toolkit Turbo run on the first evaluation."
+ "notes": "fal trains on Z-Image base: whether a base-trained LoRA behaves the same on Z-Image Turbo (Soul's model) is unverified; AI-Toolkit trains on Turbo with the training adapter, so the first evaluation compares the two routes' files on Soul."
}
diff --git a/scripts/train/specs/fuobe-scale-surreal.json b/scripts/train/specs/fuobe-scale-surreal.json
index 2fe0900d..de0b94b7 100644
--- a/scripts/train/specs/fuobe-scale-surreal.json
+++ b/scripts/train/specs/fuobe-scale-surreal.json
@@ -32,7 +32,7 @@
}
},
"aiToolkit": {
- "arch": "zimage"
+ "arch": "zimage:turbo"
}
},
"target": {
@@ -40,5 +40,5 @@
"strength": 0.8,
"hfRepo": "fuobe/fuobe-scale-surreal"
},
- "notes": "fal trains on Z-Image base: whether a base-trained LoRA behaves the same on Z-Image Turbo (Soul's model) is unverified; compare it with the AI-Toolkit Turbo run on the first evaluation."
+ "notes": "fal trains on Z-Image base: whether a base-trained LoRA behaves the same on Z-Image Turbo (Soul's model) is unverified; AI-Toolkit trains on Turbo with the training adapter, so the first evaluation compares the two routes' files on Soul."
}
diff --git a/scripts/train/specs/fuobe-soul-core.json b/scripts/train/specs/fuobe-soul-core.json
index d1333ef9..4eb1c9ca 100644
--- a/scripts/train/specs/fuobe-soul-core.json
+++ b/scripts/train/specs/fuobe-soul-core.json
@@ -31,7 +31,7 @@
}
},
"aiToolkit": {
- "arch": "zimage"
+ "arch": "zimage:turbo"
}
},
"target": {
@@ -39,5 +39,5 @@
"strength": 0.6,
"hfRepo": "fuobe/fuobe-soul-core"
},
- "notes": "Replaces the AWPortrait-Z + Lenovo pair in Soul's core slot once it wins the evaluation (scripts/eval). fal trains on Z-Image base: whether a base-trained LoRA behaves the same on Z-Image Turbo (Soul's model) is unverified; compare it with the AI-Toolkit Turbo run on the first evaluation."
+ "notes": "Replaces the AWPortrait-Z + Lenovo pair in Soul's core slot once it wins the evaluation (scripts/eval). fal trains on Z-Image base: whether a base-trained LoRA behaves the same on Z-Image Turbo (Soul's model) is unverified; AI-Toolkit trains on Turbo with the training adapter, so the first evaluation compares the two routes' files on Soul."
}
diff --git a/src/lib/training-kit.ts b/src/lib/training-kit.ts
index fa63941c..2a993898 100644
--- a/src/lib/training-kit.ts
+++ b/src/lib/training-kit.ts
@@ -226,6 +226,17 @@ export interface DatasetFile {
sha256: string;
}
+/**
+ * The dataset folder as the kit read it: every file in it other than a caption (whatever its extension, since a
+ * trainer reads more kinds than the spec's media), each caption's text by name, and anything else in it (a folder, a
+ * link), which the check refuses.
+ */
+export interface DatasetFolder {
+ files: DatasetFile[];
+ captions: Record<string, string>;
+ other?: string[];
+}
+
/** What is wrong with one item of a log (empty when it is complete). */
export function itemProblems(item: DataLogItem, media?: TrainingSpec["media"]): string[] {
const out: string[] = [];
@@ -253,9 +264,10 @@ export function itemProblems(item: DataLogItem, media?: TrainingSpec["media"]):
/**
* What stops a job from starting: the log's own gaps, its size against the spec, and, given the dataset folder, any
- * file missing from the log, logged but not there, or changed since it was logged, and any file without a caption.
+ * file missing from the log, logged but not there, or changed since it was logged, anything in the folder that is not
+ * logged media or a caption, and any file whose caption is missing, empty or without the trigger.
*/
-export function dataLogProblems(log: DataLog, spec: Pick<TrainingSpec, "id" | "media" | "dataset">, folder?: { files: DatasetFile[]; captions: string[] }): string[] {
+export function dataLogProblems(log: DataLog, spec: Pick<TrainingSpec, "id" | "media" | "dataset"> & { trigger?: string }, folder?: DatasetFolder): string[] {
const out: string[] = [];
if (log.lora !== spec.id) out.push(`the log is for ${log.lora}, not ${spec.id}`);
const n = log.items?.length ?? 0;
@@ -269,25 +281,138 @@ export function dataLogProblems(log: DataLog, spec: Pick<TrainingSpec, "id" | "m
if (folder) {
const logged = new Map((log.items ?? []).map((i) => [i.file, i]));
const present = new Map(folder.files.map((f) => [f.name, f]));
+ const kind = spec.media === "image" ? "an image" : "a clip";
+ for (const name of folder.other ?? []) out.push(`${name} is a folder or a link: the dataset folder holds only logged files and their captions`);
for (const f of folder.files) {
const item = logged.get(f.name);
+ if (!MEDIA[spec.media].test(f.name)) {
+ // A trainer reads more than the spec's media (AI-Toolkit takes .mkv clips, and a still as a one-frame clip).
+ out.push(`${f.name} is not ${kind} the spec trains on: the dataset folder holds only logged files and their captions`);
+ continue;
+ }
if (!item) out.push(`${f.name} is in the dataset but not in the log`);
else if (item.sha256 !== f.sha256) out.push(`${f.name} changed since it was logged (SHA256 differs)`);
- const stem = f.name.replace(/\.[^.]+$/, "");
- if (!folder.captions.includes(`${stem}.txt`)) out.push(`${f.name} has no caption (${stem}.txt)`);
+ const caption = `${f.name.replace(/\.[^.]+$/, "")}.txt`;
+ const text = folder.captions[caption];
+ if (text === undefined) out.push(`${f.name} has no caption (${caption})`);
+ else if (!text.trim()) out.push(`${caption} is empty`);
+ else if (spec.trigger && !new RegExp(`\\b${spec.trigger}\\b`).test(text)) out.push(`${caption} does not have the trigger ${spec.trigger}`);
}
for (const name of logged.keys()) if (!present.has(name)) out.push(`${name} is logged but not in the dataset`);
}
return out;
}
-/** The half of a log that is published next to the file: no release references, just that they exist. */
+/**
+ * The files a trainer is given: the logged media and their captions, by name. The kit zips exactly these for the
+ * hosted trainer, so the fal route trains on what the check passed.
+ */
+export function datasetZipNames(log: DataLog): string[] {
+ return (log.items ?? []).flatMap((i) => [i.file, `${i.file.replace(/\.[^.]+$/, "")}.txt`]).sort();
+}
+
+/**
+ * The half of a log that is published next to the file. Each item keeps its file, hash, source, licence, date and
+ * whether people appear (and that a release is on file). Proof and author stay private (receipts, contracts, call
+ * sheets, people's names), except for a CC0 or public-domain original, whose public page and author are credited.
+ */
export function publicLog(log: DataLog) {
return {
lora: log.lora,
version: log.version,
reviewedAt: log.reviewedAt,
- items: log.items.map(({ consent, ...item }) => ({ ...item, ...(item.people && { consent: consent ? "signed release covering AI training, on file" : "missing" }) })),
+ items: log.items.map((i) => {
+ const open = (i.source === "cc0" || i.source === "public-domain") && /^https:\/\//.test(i.proof ?? "");
+ return {
+ file: i.file,
+ sha256: i.sha256,
+ source: i.source,
+ licence: i.licence,
+ date: i.date,
+ ...(i.source === "licensed" && { aiTraining: i.aiTraining === true }),
+ ...(open ? { original: i.proof, author: i.author } : { proof: "on file" }),
+ people: i.people,
+ ...(i.people && { consent: i.consent ? "signed release covering AI training, on file" : "missing" }),
+ };
+ }),
+ };
+}
+
+// ── Publishing ──────────────────────────────────────────────────────────────────────────────────────────────────
+
+/** The route a trained file came from. */
+export type TrainingRoute = "fal" | "ai-toolkit";
+
+/**
+ * The Hugging Face repo each trainer trains on (read on the Hub 2026-11-02: all three Apache-2.0). fal's z-image-trainer
+ * and AI-Toolkit's zimage arch train on Z-Image base, the Turbo trainer and zimage:turbo on Z-Image Turbo.
+ */
+const TRAINED_ON: Record<string, string> = {
+ "fal-ai/z-image-trainer": "Tongyi-MAI/Z-Image",
+ "fal-ai/z-image-turbo-trainer-v2": "Tongyi-MAI/Z-Image-Turbo",
+ "fal-ai/wan-22-trainer/i2v-a14b": "Wan-AI/Wan2.2-I2V-A14B",
+ zimage: "Tongyi-MAI/Z-Image",
+ "zimage:turbo": "Tongyi-MAI/Z-Image-Turbo",
+ wan22_14b_i2v: "Wan-AI/Wan2.2-I2V-A14B",
+};
+
+/** The model card's base_model: the Hub id of the model the route trained on (not the library's base name). */
+export function hfBaseModel(spec: TrainingSpec, route: TrainingRoute): string {
+ const key = route === "fal" ? spec.routes.fal.trainer : spec.routes.aiToolkit.arch;
+ const id = TRAINED_ON[key];
+ if (!id) throw new Error(`${spec.id}: no Hugging Face base model known for ${key}`);
+ return id;
+}
+
+/** What the operator says about the trained file's licence (kit.mjs publish --licence, --commercial, --hosted-ok). */
+export interface LicenceChoice {
+ /** An SPDX id in lower case, as the Hub takes it (apache-2.0), or a name for a licence of its own. */
+ licence?: string;
+ commercial?: boolean;
+ hostedOk?: boolean;
+}
+
+/** The trained file's licence snapshot (what Settings → Models & licences shows) and the model card's licence. */
+export interface TrainedLicence {
+ licence: string;
+ commercial: boolean;
+ hostedOk: boolean;
+ /** The card's `license` (an SPDX id, or "other" with licenseName). */
+ card: { license: string; licenseName?: string };
+}
+
+const HUB_LICENCES = new Set(["apache-2.0", "mit", "cc0-1.0", "cc-by-4.0", "cc-by-sa-4.0", "cc-by-nc-4.0", "cc-by-nc-sa-4.0", "openrail++"]);
+
+/**
+ * The trained file's licence, from its data-licence log. Data that is all Fuobe's own, CC0 or public domain defaults to
+ * Apache-2.0 (the base models' own licence), commercial and hostable; the operator may say otherwise. A dataset with
+ * licensed items has no default: the stock licence can limit what the trained file may do, so the operator states the
+ * licence, commercial use and hosting. The snapshot names the data's licences either way.
+ */
+export function trainedLicence(log: DataLog, choice: LicenceChoice = {}): { snapshot?: TrainedLicence; problems: string[] } {
+ const items = log.items ?? [];
+ const licensed = items.filter((i) => i.source === "licensed");
+ const data = [...new Set(items.map((i) => i.licence.trim()))].sort();
+ const sources = [...new Set(items.map((i) => i.source))].sort();
+ const problems: string[] = [];
+ if (licensed.length) {
+ const what = `${licensed.length} licensed file(s) (${[...new Set(licensed.map((i) => i.licence.trim()))].join("; ")})`;
+ if (!choice.licence) problems.push(`${what}: say the trained file's licence (--licence)`);
+ if (choice.commercial === undefined) problems.push(`${what}: say whether outputs may be sold (--commercial yes|no)`);
+ if (choice.hostedOk === undefined) problems.push(`${what}: say whether hosts may run it (--hosted-ok yes|no)`);
+ }
+ if (problems.length) return { problems };
+ const spdx = (choice.licence ?? "apache-2.0").trim();
+ const known = HUB_LICENCES.has(spdx.toLowerCase());
+ const name = spdx.toLowerCase() === "apache-2.0" ? "Apache-2.0" : spdx;
+ return {
+ problems,
+ snapshot: {
+ licence: `${name} (Fuobe-trained; data: ${sources.join(", ")}; ${data.join("; ")}; data-licence log)`,
+ commercial: choice.commercial ?? true,
+ hostedOk: choice.hostedOk ?? true,
+ card: known ? { license: spdx.toLowerCase() } : { license: "other", licenseName: spdx.toLowerCase().replace(/[^a-z0-9.-]+/g, "-") },
+ },
};
}
diff --git a/tests/training-kit.test.ts b/tests/training-kit.test.ts
index 6ef39f18..7cbab937 100644
--- a/tests/training-kit.test.ts
+++ b/tests/training-kit.test.ts
@@ -1,8 +1,11 @@
-import { execFileSync, spawnSync } from "node:child_process";
+import { execFile, execFileSync, spawnSync } from "node:child_process";
import crypto from "node:crypto";
import fs from "node:fs";
+import http from "node:http";
+import type { AddressInfo } from "node:net";
import os from "node:os";
import path from "node:path";
+import { promisify } from "node:util";
import { describe, expect, it } from "vitest";
import { getPreset } from "@/lib/catalog";
import { LORA_LIBRARY, MOTION_EFFECT_LORAS, PLANNED_LORAS } from "@/lib/catalog/lora-library.generated";
@@ -10,13 +13,16 @@ import { getTrainer } from "@/lib/catalog/training";
import {
aiToolkitConfig,
dataLogProblems,
+ datasetZipNames,
falTrainingPayload,
+ hfBaseModel,
MOTION_LIBRARY,
motionLibraryClip,
motionLibraryProblems,
publicLog,
specCostUsd,
specProblems,
+ trainedLicence,
type DataLog,
type DataLogItem,
type MotionClip,
@@ -99,9 +105,14 @@ describe("training kit: job specs (scripts/train/specs)", () => {
expect(turbo.network).toEqual({ type: "lora", linear: 16, linear_alpha: 16 });
expect(turbo.train.steps).toBe(1800);
expect(turbo.trigger_word).toBe("fbcctv");
- const base = aiToolkitConfig(spec("fuobe-soul-core"), "/d", "/o").config.process[0] as unknown as Proc;
+ // Every Z-Image spec trains on Turbo on the GPU (fal's z-image-trainer is the base route), so one route matches Soul.
+ for (const s of specs.filter((x) => x.base === "z-image-turbo")) expect(s.routes.aiToolkit.arch, s.id).toBe("zimage:turbo");
+ const core = aiToolkitConfig(spec("fuobe-soul-core"), "/d", "/o").config.process[0] as unknown as Proc;
+ expect(core.model.arch).toBe("zimage:turbo");
+ expect(core.network.linear).toBe(32);
+ const soulBase = spec("fuobe-soul-core");
+ const base = aiToolkitConfig({ ...soulBase, routes: { ...soulBase.routes, aiToolkit: { arch: "zimage" } } }, "/d", "/o").config.process[0] as unknown as Proc;
expect(base.model).toMatchObject({ name_or_path: "Tongyi-MAI/Z-Image", arch: "zimage" });
- expect(base.network.linear).toBe(32);
const wan = aiToolkitConfig(spec("fuobe-timelapse"), "/clips", "/o").config.process[0] as unknown as Proc;
expect(wan.model).toMatchObject({ arch: "wan22_14b_i2v", model_kwargs: { train_high_noise: true, train_low_noise: true } });
expect(wan.datasets[0]).toMatchObject({ folder_path: "/clips", num_frames: 41, fps: 16 });
@@ -137,21 +148,69 @@ describe("training kit: data-licence logs", () => {
expect(dataLogProblems(log("fuobe-cctv", 40, { people: true, consent }), s)).toEqual([]);
expect(dataLogProblems(log("fuobe-cctv", 40, { people: true, consent: { ...consent, scope: ["marketing"] } }), s).join()).toMatch(/cover AI training/);
expect(dataLogProblems(log("fuobe-cctv", 40, { people: true, consent: { ...consent, adults: false } }), s).join()).toMatch(/only adults/);
- // The published half keeps that a release exists, not its reference.
- const pub = publicLog(log("fuobe-cctv", 1, { people: true, consent }));
- expect(JSON.stringify(pub)).not.toMatch(/release-2026/);
- expect(pub.items[0]).toMatchObject({ people: true, consent: "signed release covering AI training, on file" });
+ // The published half keeps that a release exists, not its reference, nor the proof or the author.
+ const pub = publicLog(log("fuobe-cctv", 1, { people: true, consent, author: "Jane Doe" }));
+ expect(JSON.stringify(pub)).not.toMatch(/release-2026|call sheet|Jane Doe/);
+ expect(pub.items[0]).toMatchObject({ people: true, consent: "signed release covering AI training, on file", proof: "on file", source: "own-shoot", sha256: sha("001.jpg") });
+ // A CC0 original keeps its public page and author as a credit.
+ const cc0 = publicLog(log("fuobe-cctv", 1, { source: "cc0", licence: "CC0-1.0", proof: "https://example.org/photo/1", author: "A. Photographer" }));
+ expect(cc0.items[0]).toMatchObject({ original: "https://example.org/photo/1", author: "A. Photographer" });
+ expect(cc0.items[0]).not.toHaveProperty("proof");
});
it("checks the log against the dataset folder: every file logged, unchanged and captioned", () => {
const l = log("fuobe-cctv", 40);
const files = l.items.map((i) => ({ name: i.file, sha256: i.sha256 }));
- const captions = l.items.map((i) => i.file.replace(".jpg", ".txt"));
+ const captions = Object.fromEntries(l.items.map((i) => [i.file.replace(".jpg", ".txt"), "fbcctv style, a parking garage at night"]));
+ const without = (name: string) => Object.fromEntries(Object.entries(captions).filter(([k]) => k !== name));
expect(dataLogProblems(l, s, { files, captions })).toEqual([]);
expect(dataLogProblems(l, s, { files: [...files, { name: "041.jpg", sha256: sha("x") }], captions }).join()).toMatch(/041.jpg is in the dataset but not in the log/);
expect(dataLogProblems(l, s, { files: files.slice(1), captions }).join()).toMatch(/001.jpg is logged but not in the dataset/);
expect(dataLogProblems(l, s, { files: [{ ...files[0], sha256: sha("edited") }, ...files.slice(1)], captions }).join()).toMatch(/changed since it was logged/);
- expect(dataLogProblems(l, s, { files, captions: captions.slice(1) }).join()).toMatch(/001.jpg has no caption/);
+ expect(dataLogProblems(l, s, { files, captions: without("001.txt") }).join()).toMatch(/001.jpg has no caption/);
+ // A caption says something, with the trigger.
+ expect(dataLogProblems(l, s, { files, captions: { ...captions, "002.txt": " " } }).join()).toMatch(/002.txt is empty/);
+ expect(dataLogProblems(l, s, { files, captions: { ...captions, "003.txt": "a parking garage at night" } }).join()).toMatch(/003.txt does not have the trigger fbcctv/);
+ expect(dataLogProblems(l, s, { files, captions: { ...captions, "003.txt": "fbcctvx garage" } }).join()).toMatch(/003.txt does not have the trigger/);
+ // Nothing else may sit in the folder: a trainer reads more kinds of file than the spec's media.
+ expect(dataLogProblems(l, s, { files: [...files, { name: "notes.pdf", sha256: sha("n") }], captions }).join()).toMatch(/notes.pdf is not an image the spec trains on/);
+ expect(dataLogProblems(l, s, { files, captions, other: ["extra"] }).join()).toMatch(/extra is a folder or a link/);
+ const push = spec("fuobe-push-in");
+ const clips: DataLog = { ...log("fuobe-push-in", 20), items: log("fuobe-push-in", 20).items.map((i) => ({ ...i, file: i.file.replace(".jpg", ".mp4") })) };
+ const clipFiles = clips.items.map((i) => ({ name: i.file, sha256: i.sha256 }));
+ const clipCaptions = Object.fromEntries(clips.items.map((i) => [i.file.replace(".mp4", ".txt"), "fbpushin, a slow push in on the eyes"]));
+ expect(dataLogProblems(clips, push, { files: clipFiles, captions: clipCaptions })).toEqual([]);
+ const stray = dataLogProblems(clips, push, { files: [...clipFiles, { name: "stray.mkv", sha256: sha("m") }, { name: "still.jpg", sha256: sha("j") }], captions: clipCaptions }).join("\n");
+ expect(stray).toMatch(/stray.mkv is not a clip the spec trains on/);
+ expect(stray).toMatch(/still.jpg is not a clip the spec trains on/);
+ // The zip for the hosted trainer is exactly the logged files and their captions.
+ expect(datasetZipNames(log("fuobe-cctv", 2))).toEqual(["001.jpg", "001.txt", "002.jpg", "002.txt"]);
+ });
+});
+
+describe("training kit: publishing", () => {
+ it("names the Hugging Face repo each route trained on as the card's base model", () => {
+ expect(hfBaseModel(spec("fuobe-soul-core"), "fal")).toBe("Tongyi-MAI/Z-Image");
+ expect(hfBaseModel(spec("fuobe-soul-core"), "ai-toolkit")).toBe("Tongyi-MAI/Z-Image-Turbo");
+ expect(hfBaseModel(spec("fuobe-cctv"), "fal")).toBe("Tongyi-MAI/Z-Image-Turbo");
+ expect(hfBaseModel(spec("fuobe-push-in"), "fal")).toBe("Wan-AI/Wan2.2-I2V-A14B");
+ expect(hfBaseModel(spec("fuobe-push-in"), "ai-toolkit")).toBe("Wan-AI/Wan2.2-I2V-A14B");
+ for (const s of specs) for (const r of ["fal", "ai-toolkit"] as const) expect(hfBaseModel(s, r)).toMatch(/^[\w.-]+\/[\w.-]+$/);
+ });
+
+ it("takes the licence snapshot from the data-licence log, never assuming one for licensed data", () => {
+ const own = trainedLicence(log("fuobe-cctv", 40));
+ expect(own.snapshot).toMatchObject({ commercial: true, hostedOk: true, card: { license: "apache-2.0" } });
+ expect(own.snapshot!.licence).toMatch(/^Apache-2.0 .*own-shoot.*Fuobe's own/);
+ const stock = log("fuobe-cctv", 40, { source: "licensed", aiTraining: true, licence: "StockCo Extended AI" });
+ const asked = trainedLicence(stock);
+ expect(asked.snapshot).toBeUndefined();
+ expect(asked.problems.join()).toMatch(/StockCo Extended AI.*--licence/);
+ expect(asked.problems.join()).toMatch(/--commercial/);
+ expect(asked.problems.join()).toMatch(/--hosted-ok/);
+ const said = trainedLicence(stock, { licence: "StockCo-Derivative", commercial: true, hostedOk: false });
+ expect(said.snapshot).toMatchObject({ commercial: true, hostedOk: false, card: { license: "other", licenseName: "stockco-derivative" } });
+ expect(said.snapshot!.licence).toMatch(/StockCo-Derivative .*licensed.*StockCo Extended AI/);
});
});
@@ -285,7 +344,7 @@ describe("training kit: the command line", () => {
}
});
- it("writes both routes' configs once the log matches the dataset, and dry-runs a publish", () => {
+ it("writes both routes' configs once the log matches the dataset, and dry-runs a publish", async () => {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-kit-ok-"));
const data = path.join(tmp, "data");
const logs = path.join(tmp, "logs");
@@ -299,22 +358,64 @@ describe("training kit: the command line", () => {
fs.writeFileSync(path.join(logs, "fuobe-cctv.json"), JSON.stringify(l));
const env = { ...process.env, FUOBE_TRAIN_LOGS: logs };
const run = (args: string[]) => execFileSync("node", [KIT, ...args], { cwd: ROOT, env, stdio: "pipe" }).toString();
+ // The job downloads the zip URL, so it runs while this process serves the zip.
+ const runAsync = (args: string[]) =>
+ promisify(execFile)("node", [KIT, ...args], { cwd: ROOT, env }).then(
+ (r) => r.stdout,
+ (e: { stdout: string; stderr: string; code: number }) => ({ refused: e.code, out: e.stdout + e.stderr }),
+ );
+ let served = Buffer.from("");
+ const server = http.createServer((_, res) => res.end(served));
+ await new Promise<void>((r) => server.listen(0, "127.0.0.1", r));
+ const zipUrl = `http://127.0.0.1:${(server.address() as AddressInfo).port}/cctv.zip`;
try {
expect(run(["check", "fuobe-cctv", "--dataset", data])).toMatch(/fuobe-cctv: ready/);
const out = path.join(tmp, "out");
- expect(run(["job", "fuobe-cctv", "--dataset", data, "--zip-url", "https://example.com/cctv.zip", "--out", out])).toMatch(/Not run here/);
+ // First the zip of exactly the checked files; the fal request waits for its URL.
+ expect(run(["job", "fuobe-cctv", "--dataset", data, "--out", out])).toMatch(/upload .*fuobe-cctv\.dataset\.zip/);
expect(JSON.parse(fs.readFileSync(path.join(out, "fuobe-cctv.aitk.json"), "utf8")).config.process[0].datasets[0].folder_path).toBe(data);
- expect(JSON.parse(fs.readFileSync(path.join(out, "fuobe-cctv.fal.json"), "utf8"))).toEqual({ endpoint: "fal-ai/z-image-turbo-trainer-v2", input: { image_data_url: "https://example.com/cctv.zip", steps: 1800, learning_rate: 0.0001, default_caption: "fbcctv style" } });
+ 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);
+ // 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/) });
+ served = zip;
+ expect(await runAsync(["job", "fuobe-cctv", "--dataset", data, "--zip-url", zipUrl, "--out", out])).toMatch(/Not run here/);
+ expect(JSON.parse(fs.readFileSync(path.join(out, "fuobe-cctv.fal.json"), "utf8"))).toEqual({
+ endpoint: "fal-ai/z-image-turbo-trainer-v2",
+ input: { image_data_url: zipUrl, steps: 1800, learning_rate: 0.0001, default_caption: "fbcctv style" },
+ datasetZip: { file: "fuobe-cctv.dataset.zip", sha256: crypto.createHash("sha256").update(zip).digest("hex") },
+ });
+ // A stray file the trainer would also read stops the job.
+ fs.writeFileSync(path.join(data, "extra.webm"), "unlogged");
+ const stray = spawnSync("node", [KIT, "job", "fuobe-cctv", "--dataset", data], { cwd: ROOT, env, encoding: "utf8" });
+ expect({ status: stray.status, out: stray.stdout + stray.stderr }).toEqual({ status: 1, out: expect.stringMatching(/fuobe-cctv: not ready\n {2}data-licence log: extra\.webm is not an image the spec trains on/) });
+ fs.rmSync(path.join(data, "extra.webm"));
// A changed image stops the job.
fs.writeFileSync(path.join(data, "007.jpg"), "edited");
- expect(refused(["job", "fuobe-cctv", "--dataset", data]).status).toBe(1);
+ const changed = spawnSync("node", [KIT, "job", "fuobe-cctv", "--dataset", data], { cwd: ROOT, env, encoding: "utf8" });
+ expect({ status: changed.status, out: changed.stdout }).toEqual({ status: 1, out: expect.stringMatching(/007\.jpg changed since it was logged/) });
const file = path.join(tmp, "trained.safetensors");
fs.writeFileSync(file, "weights");
- const dry = execFileSync("node", [KIT, "publish", "fuobe-cctv", "--file", file], { cwd: ROOT, env: { ...env, TMPDIR: tmp }, stdio: "pipe" }).toString();
+ const publish = (args: string[]) => execFileSync("node", [KIT, "publish", "fuobe-cctv", "--file", file, ...args], { cwd: ROOT, env: { ...env, TMPDIR: tmp }, stdio: "pipe" }).toString();
+ expect(() => publish([])).toThrow(/--route fal\|ai-toolkit/);
+ const dry = publish(["--route", "ai-toolkit"]);
expect(dry).toMatch(/Dry run: nothing uploaded/);
expect(dry).toContain(`"url": "https://huggingface.co/fuobe/fuobe-cctv/resolve/main/fuobe-cctv.safetensors"`);
expect(dry).toContain(`"sha256": "${sha("weights")}"`);
+ expect(dry).toMatch(/"licence": "Apache-2.0 \(Fuobe-trained; data: own-shoot/);
+ const stage = fs.readdirSync(tmp).find((n) => n.startsWith("fuobe-publish-fuobe-cctv-"))!;
+ const card = fs.readFileSync(path.join(tmp, stage, "README.md"), "utf8");
+ expect(card).toMatch(/^---\nlicense: apache-2.0\nbase_model: Tongyi-MAI\/Z-Image-Turbo\nbase_model_relation: adapter\n/);
+ expect(fs.readFileSync(path.join(tmp, stage, "data-licence-log.json"), "utf8")).not.toMatch(/call sheet|Fuobe team/);
+ // Licensed data: the licence is said, not assumed.
+ fs.writeFileSync(path.join(logs, "fuobe-cctv.json"), JSON.stringify(log("fuobe-cctv", 40, { source: "licensed", aiTraining: true, licence: "StockCo AI" })));
+ expect(() => publish(["--route", "fal"])).toThrow(/recorded, not assumed/);
+ expect(publish(["--route", "fal", "--licence", "StockCo-Derivative", "--commercial", "no", "--hosted-ok", "no"])).toMatch(/"commercial": false,\s*"hostedOk": false/);
} finally {
+ server.close();
fs.rmSync(tmp, { recursive: true, force: true });
}
});
@@ -329,7 +430,7 @@ describe("training kit: the command line", () => {
const file = path.join(dir, "trained.safetensors");
fs.writeFileSync(file, "weights");
try {
- expect(refused(["publish", "fuobe-cctv", "--file", file])).toEqual({ status: 1, out: expect.stringMatching(/only with a complete data-licence log/) });
+ expect(refused(["publish", "fuobe-cctv", "--file", file, "--route", "fal"])).toEqual({ status: 1, out: expect.stringMatching(/only with a complete data-licence log/) });
} finally {
fs.rmSync(dir, { recursive: true, force: true });
}