Repository navigation
Commands
Every verb prints one JSON object. Exit codes: 0 success, 1 a usage error (new with a bad kind or an existing file, rerun onto an existing recipe), 2 a gate refused or leak found something. Outputs below were run on Windows; paths under the temporary test folder are shown as <tmp>.
tw.py new <kind> <name> [--out FILE] [--force]
Kinds: image-lora, video-lora, voice, llm. Writes <name>.recipe.json (or --out) and refuses to replace an existing file unless --force is given.
python tw.py new image-lora my-style{
"ok": false,
"error": "my-style.recipe.json exists; pick a new name or --force"
}
python tw.py new audio x{
"ok": false,
"error": "kind must be one of ('image-lora', 'video-lora', 'voice', 'llm')"
}
The defaults per kind are on Recipe format.
tw.py hash <path> [--manifest] [--source TEXT]
Without --manifest, the sha256 of one file:
python tw.py hash base.safetensors{
"ok": true,
"file": "base.safetensors",
"sha256": "c2f1b96774221247cf2d2908709b53940b2a4c4b23ccc3c9dfad40f74a75c9b9"
}
With --manifest, every file under the folder with one of these extensions, sorted: .png .jpg .jpeg .webp .wav .flac .mp3 .mp4 .txt .jsonl. Caption .txt files are included. --source is written into each item; check fails an item with no source.
python tw.py hash datasets/my-style --manifest --source "own photos"{
"ok": true,
"root": "datasets\\my-style",
"count": 4,
"items": [
{
"file": "img1.png",
"sha256": "3f0aadd1667d7b31846d4aa043295e21c03f791d7d4c10ff9a150a71a9d40ea2",
"source": "own photos"
},
{
"file": "img1.txt",
"sha256": "80ab943597ec8dc055c3d1efd77b07acc2157f0de60b53ccab7375803a31ecb0",
"source": "own photos"
},
{
"file": "img2.png",
"sha256": "7a5e9fd544fdc40e6697937f9fc33daf325ea54d86e8d50ef736fac8513cfad9",
"source": "own photos"
},
{
"file": "img2.txt",
"sha256": "f8125d97960d2bea660de8f02d325b5b1b27cd49566ab7760f019036ed38a416",
"source": "own photos"
}
]
}
root is printed as given on the command line, in the operating system's path form.
tw.py check <recipe> [--shallow]
Runs the gates. --shallow leaves out the dataset hash comparison, the GPU probe and the disk floor.
tw.py config <recipe> [--trainer T] [--out FILE]
For ai-toolkit (the only trainer marked proven_on_real_trainer: true in 0.1.0) it writes a YAML job next to the recipe, named <recipe without .json>.yaml. For any other trainer it writes a neutral JSON of the settings (trainer, base, dataset and the config fields) and says the mapping is unproven:
python tw.py config my-style.recipe.json --trainer kohya --out my-style.kohya.json{
"ok": true,
"trainer": "kohya",
"config": "my-style.kohya.json",
"proven_on_real_trainer": false,
"note": "unproven mapping: run a dry run of a few steps before trusting it"
}
Always pass --out for these trainers in 0.1.0: see Known issues.
The ai-toolkit job keeps every save_every step (up to 50 saves), samples at the same interval with the recipe's seed, trains the UNet only with adamw8bit in bf16, and uses the first six eval.sheet prompts as samples ("a photo" when the sheet is empty).
tw.py run <recipe> <config> [--dry] [--steps N]
Looks the recipe's trainer up in hosts.json and starts <python> <entry> <config> from the entry script's folder. Without --dry it refuses on any failed gate. The run's log goes to <recipe>.log, and the recipe gains a runs entry with start, end, exit code and log path.
{
"ok": true,
"dry": true,
"would_run": [
"/opt/ai-toolkit/venv/bin/python",
"/opt/ai-toolkit/run.py",
"<tmp>\\my-style.ai-toolkit.yaml"
],
"fail": [],
"warn": [
"GPU busy (0% load, 11594 MB): queue behind it, never stop the other job"
],
"note": "dry run: set config.steps to a few steps in a copy and run that as the smoke test"
}
A trainer missing from hosts.json fails with no install for trainer '<name>' in <home>/hosts.json (trainers.<name>.python and .entry).
tw.py record <recipe> [--score k=v ...] [--pick NAME] [--files FILE ...]
A score that looks like a number is stored as one; anything else is kept as text. --files stores each file with its sha256. still_missing lists picked and scores while they are empty.
tw.py rerun <recipe> <new-name>
Writes <new-name>.recipe.json beside the old one with the same base, dataset, config and seed, empty runs, scores and pick, an output folder that is a sibling of the old one under the new name, and a rerun_of link. Then it runs the gates on the copy.
python tw.py rerun my-style.recipe.json my-style-r2The output repeats check's result for the new recipe and adds "note": "same seed, config and dataset hashes; compare with tw.py diff after the run".
tw.py diff <a> <b>
Compares two recipes field by field, leaving out name, runs, output, rerun_of and the scores and pick, and lists the scores side by side. Here the rerun's learning rate was halved:
python tw.py diff my-style.recipe.json my-style-r2.recipe.json{
"ok": true,
"same_recipe": false,
"recipe_differences": {
"config.lr": [
0.0001,
5e-05
]
},
"scores": {
"note": [
"best at 300",
null
],
"style_match": [
0.82,
null
]
}
}
tw.py leak [--root DIR] [--allow-no-terms]
Scans the files git tracks under DIR (every file when it is not a git repository) and reports:
- any file with a weights or media extension (
.safetensors .gguf .ckpt .pt .bin .wav .mp3 .flac .png .jpg .jpeg .webp .mp4 .mov), except under.github/images/; - any IPv4 address other than 127.0.0.1 and 0.0.0.0;
- any term from
leak-terms.txt, by its line number only, so the report never prints the term.
python tw.py leak --root repo{
"ok": false,
"terms_from": "<tmp>\\home\\leak-terms.txt",
"hits": [
{
"file": "lora.safetensors",
"why": "media or weights file"
},
{
"file": "README.md",
"why": "sidecar term #1"
}
]
}
With no leak-terms.txt it refuses rather than pass:
{
"ok": false,
"fail": [
"no leak-terms.txt in TRAINWRIGHT_HOME: the scan would prove nothing"
]
}
--allow-no-terms runs the media and address checks without a term list.
This wiki describes trainwright 0.1.0 and was last updated on 2026-11-19. The plugin is MIT licensed. Report problems in the issues.
Using it
The releases
Contributing
Elsewhere