[object Object]

← back to Wallco Ai

pilot-build-tifs.py: --all batch mode (published ids, disk guard, resumable, progress)

7b073e5c4c826054914feb50c58209fbbb41d9d3 · 2026-06-02 08:46:18 -0700 · Steve Abrams

Adds --all (every PUBLISHED design from designs.json), --all-including-unpublished,
--start/--limit (resume/chunk), --min-free-gb disk guard (aborts before a build
if free disk drops below, default 10GB), and progress logging. Skips existing
TIFs so re-runs are idempotent. For the full prod TIF batch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 7b073e5c4c826054914feb50c58209fbbb41d9d3
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Jun 2 08:46:18 2026 -0700

    pilot-build-tifs.py: --all batch mode (published ids, disk guard, resumable, progress)
    
    Adds --all (every PUBLISHED design from designs.json), --all-including-unpublished,
    --start/--limit (resume/chunk), --min-free-gb disk guard (aborts before a build
    if free disk drops below, default 10GB), and progress logging. Skips existing
    TIFs so re-runs are idempotent. For the full prod TIF batch.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 scripts/pilot-build-tifs.py | 70 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 62 insertions(+), 8 deletions(-)

diff --git a/scripts/pilot-build-tifs.py b/scripts/pilot-build-tifs.py
index ccd39a9..2c9d788 100644
--- a/scripts/pilot-build-tifs.py
+++ b/scripts/pilot-build-tifs.py
@@ -52,21 +52,75 @@ def build(base, design_id, force):
         return False, f"{design_id}: build fail: {e}"
 
 
+def free_gb():
+    import shutil
+    return shutil.disk_usage(str(ROOT)).free / (1024 ** 3)
+
+
 def main():
     ap = argparse.ArgumentParser()
     ap.add_argument("--base", default="http://127.0.0.1:9905")
     ap.add_argument("--force", action="store_true")
-    ap.add_argument("ids", nargs="+")
+    ap.add_argument("--all", action="store_true",
+                    help="build every PUBLISHED design from data/designs.json")
+    ap.add_argument("--all-including-unpublished", action="store_true",
+                    help="build EVERY design in data/designs.json (rarely needed)")
+    ap.add_argument("--start", type=int, default=0, help="skip the first N ids (resume)")
+    ap.add_argument("--limit", type=int, default=0, help="cap the number built this run")
+    ap.add_argument("--min-free-gb", type=float, default=10.0,
+                    help="abort before a build if free disk drops below this")
+    ap.add_argument("--progress-every", type=int, default=50)
+    ap.add_argument("ids", nargs="*")
     a = ap.parse_args()
+
+    if a.all or a.all_including_unpublished:
+        import json
+        p = ROOT / "data" / "designs.json"
+        arr = json.loads(p.read_text())
+        if isinstance(arr, dict):
+            arr = arr.get("designs", [])
+        ids = []
+        for d in arr:
+            if a.all and d.get("is_published") is False:
+                continue
+            try:
+                ids.append(int(d["id"]))
+            except (KeyError, ValueError, TypeError):
+                pass
+        ids = sorted(set(ids))
+    else:
+        ids = []
+        for raw in a.ids:
+            try:
+                ids.append(int(raw))
+            except ValueError:
+                print(f"{raw}: not an int")
+    if a.start:
+        ids = ids[a.start:]
+    if a.limit:
+        ids = ids[:a.limit]
+
+    total = len(ids)
+    print(f"[pilot-build-tifs] {total} ids to consider · free {free_gb():.1f} GB · base {a.base}", flush=True)
     ok_all = True
-    for raw in a.ids:
-        try:
-            did = int(raw)
-        except ValueError:
-            print(f"{raw}: not an int"); ok_all = False; continue
+    built = skipped = failed = 0
+    for i, did in enumerate(ids, 1):
+        if free_gb() < a.min_free_gb:
+            print(f"ABORT: free disk {free_gb():.1f} GB < --min-free-gb {a.min_free_gb}. "
+                  f"Built {built}, stopped at id {did} (#{i}/{total}).", flush=True)
+            return 2
         ok, msg = build(a.base, did, a.force)
-        print(("  ok  " if ok else "  FAIL ") + msg)
-        ok_all = ok_all and ok
+        if ok:
+            built += 1
+            if "exists" in msg:
+                skipped += 1
+        else:
+            failed += 1
+            ok_all = False
+        if i % a.progress_every == 0 or not ok:
+            print(f"  [{i}/{total}] built≈{built} fail={failed} free={free_gb():.1f}GB :: "
+                  + ("ok " if ok else "FAIL ") + msg, flush=True)
+    print(f"[pilot-build-tifs] DONE · considered {total} · ok {built} (skipped-existing {skipped}) · failed {failed} · free {free_gb():.1f} GB", flush=True)
     return 0 if ok_all else 1
 
 

← ad8604f PDP: mtime cache-bust /js/color-dots.js so JS fixes land on  ·  back to Wallco Ai  ·  la-toile: add palm vision-gate + tighten panel gate (negativ b62bf3a →