Python
lab: runs that wait for review before publishing, six new reference portraits
neuregexd3a72d13c042
diff --git a/lab/cases.json b/lab/cases.jsonindex 4e39148..18ea6c1 100644--- a/lab/cases.json+++ b/lab/cases.json@@ -430,6 +430,13 @@"overrides": [{"node": "fm_grow", "field": "expand", "value": 0}, {"node": "4", "field": "text", "value": "Give this person exactly the face of the person in image 1: the same eyes, nose, mouth, brows and face shape as image 1. Keep this photo's own hairline and hair; match its head angle, expression, lighting and skin tone."}],"note": "Same as G with the pair the other way round: does the head still turn? Result in run 20261024-033622-l40s: works: the long-haired woman gets the short-bob woman's face, head angle kept"},+ {"id": "refx-face-a-1", "app": "z-image", "values": {"prompt": "Portrait photo of a Mexican woman in her late twenties with short dark wavy hair and a denim jacket, warm brown skin, light freckles, natural skin texture with visible pores, no retouching, soft window light from the side, neutral grey background, shot on an 85mm lens", "width": 1280, "height": 768}, "note": "Candidate for ref-face-a: the old one came out as a glossy East Asian face, the model's default when no one is named."},+ {"id": "refx-face-a-2", "app": "z-image", "values": {"prompt": "Portrait photo of a woman in her early thirties from southern Spain with short black hair and a denim jacket, olive skin, a small mole on her cheek, natural skin texture with visible pores, no retouching, soft studio light, neutral grey background, realistic photo", "width": 1280, "height": 768}, "note": "Candidate for ref-face-a, second look."},+ {"id": "refx-woman-a-1", "app": "z-image", "values": {"prompt": "Waist-up portrait photo of a white woman in her early thirties with long wavy light brown hair and freckles, wearing a cream knit sweater, gentle smile, looking at the camera, natural skin texture with visible pores, no retouching, soft daylight from a window, plain warm beige background, realistic photo", "width": 768, "height": 1280}, "note": "Candidate for ref-fx-woman-a (the face in face swap and the morph examples)."},+ {"id": "refx-woman-a-2", "app": "z-image", "values": {"prompt": "Waist-up portrait photo of a Brazilian woman in her late twenties with long curly dark brown hair, wearing a cream knit sweater, gentle smile, looking at the camera, natural skin texture with visible pores, no retouching, soft daylight, plain warm beige background, realistic photo", "width": 768, "height": 1280}, "note": "Candidate for ref-fx-woman-a, second look."},+ {"id": "refx-woman-b-1", "app": "z-image", "values": {"prompt": "Waist-up portrait photo of a Black woman in her late thirties with short natural coily hair, wearing a navy blazer, calm expression, looking at the camera, natural skin texture with visible pores, no retouching, soft studio light, plain light blue background, realistic photo", "width": 768, "height": 1280}, "note": "Candidate for ref-fx-woman-b (laughing, money rain, four morph transformations, outfit shot)."},+ {"id": "refx-woman-b-2", "app": "z-image", "values": {"prompt": "Waist-up portrait photo of a Lebanese woman in her late thirties with shoulder-length dark curly hair, wearing a navy blazer, calm expression, looking at the camera, natural skin texture with visible pores, no retouching, soft studio light, plain light blue background, realistic photo", "width": 768, "height": 1280}, "note": "Candidate for ref-fx-woman-b, second look."},+{"id": "ref-tpl-sketch", "app": "z-image", "values": {"prompt": "A rough pencil sketch on white paper of a cat sitting on a windowsill next to a potted plant, loose lines, no color", "width": 1024, "height": 1024},"note": "Reference sketch for Sketch to Real."},{"id": "ref-tpl-sign", "app": "z-image", "values": {"prompt": "Photo of a small bakery storefront with a wooden sign above the door that reads OPEN in bold white letters, daylight, photorealistic", "width": 1280, "height": 768},diff --git a/lab/publish.py b/lab/publish.pyindex 47a05e1..4e6aeee 100644--- a/lab/publish.py+++ b/lab/publish.py@@ -2,6 +2,7 @@"""Publish one example per app from a lab run into the web UI.python lab/publish.py lab/results/<run_id>+ python lab/publish.py lab/results/<run_id> --skip fx-crying,tpl-idol # all but these casesFor every app it picks a case that succeeded (the one marked "showcase" in lab/cases.json ifit ran, otherwise the first one in file order) and copies that case's web versions into@@ -130,9 +131,17 @@ def publish_options(run_dir: Path, ok: list[dict], dest: Path, manifest: dict, odef main(argv: list[str] | None = None) -> int:ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])ap.add_argument("run_dir", type=Path)+ ap.add_argument("--skip", default="", help="case ids not to publish (comma-separated): their apps keep what they had")a = ap.parse_args(argv)run_dir = a.run_dir.resolve()results = read_results(run_dir)+ skip = {s for s in a.skip.split(",") if s}+ if skip:+ unknown = skip - set(results)+ if unknown:+ print(f"--skip: not in this run: {', '.join(sorted(unknown))}", file=sys.stderr)+ return 2+ results = {k: v for k, v in results.items() if k not in skip}cases = json.loads((ROOT / "lab" / "cases.json").read_text(encoding="utf-8"))["cases"]rank = {c["id"]: i for i, c in enumerate(cases)}showcase = {c["id"] for c in cases if c.get("showcase")}diff --git a/tools/lab_queue.py b/tools/lab_queue.pyindex 46f4759..e37bcfb 100644--- a/tools/lab_queue.py+++ b/tools/lab_queue.py@@ -9,7 +9,10 @@ Whoever wants a run (you, or an assistant working in this folder) writes lab/que{"only": "tpl-face-swap,tplx-face-swap-*", "shards": 1, "note": "why this run"}-The watcher runs exactly `modal run lab/lab_modal.py --only <only> [--shards N]` from the repo root, prints+"publish": false adds --no-publish: the run is copied to lab/results/ for review but web/examples/ stays as it is+(publish what passed later with `python lab/publish.py lab/results/<run_id> --skip <case ids>`).++The watcher runs exactly `modal run lab/lab_modal.py --only <only> [--shards N] [--no-publish]` from the repo root, printsthe output and saves it to lab/queue/<name>.log, then writes lab/queue/<name>.done.json (exit code, run id,"N/M ok", times) and renames the job to <name>.job.done.json. Nothing else can be asked for: no deploy, no otherscript, no extra arguments. "only" may hold case ids and fnmatch patterns from lab/cases.json and nothing else.@@ -50,14 +53,16 @@ def check_job(name: str, job: dict, max_cases: int) -> tuple[list[str] | None, s"""The case ids a job selects, or None and the reason it is refused."""if not NAME.match(name):return None, "job name must be letters, digits, - and _"- if set(job) - {"only", "shards", "note"}:- return None, f"unknown keys: {sorted(set(job) - {'only', 'shards', 'note'})}"+ if set(job) - {"only", "shards", "note", "publish"}:+ return None, f"unknown keys: {sorted(set(job) - {'only', 'shards', 'note', 'publish'})}"only = job.get("only")if not isinstance(only, str) or not ONLY.match(only):return None, "only must be case ids or patterns: a-z 0-9 - * ? and commas"shards = job.get("shards", 1)if not isinstance(shards, int) or not 1 <= shards <= 4:return None, "shards must be 1 to 4"+ if not isinstance(job.get("publish", True), bool):+ return None, "publish must be true or false"ids = case_ids()wanted = [w for w in only.split(",") if w]unknown = [w for w in wanted if not any(fnmatch(i, w) for i in ids)]@@ -90,6 +95,8 @@ def run_job(name: str, job: dict, picked: list[str]) -> dict:args = modal_cmd() + ["run", "lab/lab_modal.py", "--only", job["only"]]if job.get("shards", 1) > 1:args += ["--shards", str(job["shards"])]+ if job.get("publish", True) is False:+ args += ["--no-publish"]log_path = QUEUE / f"{name}.log"started, t0 = now(), time.time()print(f"\n[{started}] {name}: {len(picked)} cases · {' '.join(args[1:])}", flush=True)