vinylgauntlet/assets/enqueue.py
type-two 0a71e07078 Vinyl Gauntlet: core game (Gauntlet II re-skin) + FLUX asset queue
Top-down arcade maze shooter in Phaser 3. Steps 1-6 of plan.md complete and
verified: vibe drain, generators/swarm, pooling, combat, Sound Guy, airhorn,
trainspot exit, level flow, announcer. assets/ holds the FLUX prompt manifest
+ MODELBEAST enqueuer for the Step 7 sprite pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 23:17:19 +10:00

55 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Enqueue Vinyl Gauntlet's asset queue into MODELBEAST as flux_local jobs.
Runs from the MODELBEAST checkout (imports its server modules) and inserts jobs
straight into the jobs table as the owner — the jobs table IS the queue. After
running, restart the MB server (scripts/serve.sh) so the runner picks them up.
cd ~/MODELBEAST && ./venvs/... no — use the app env:
/opt/homebrew/bin/uv run python /path/to/vinylgauntlet/assets/enqueue.py
Writes assets/queue.lock.json mapping job_id -> asset name so outputs can be
collected later from data/jobs/<job_id>/.
"""
import json, sys
from pathlib import Path
MB = Path.home() / "MODELBEAST"
sys.path.insert(0, str(MB))
import server.db as db # noqa: E402
import server.runner as runner # noqa: E402
HERE = Path(__file__).resolve().parent
q = json.loads((HERE / "queue.json").read_text())
styles = q["style"]
defaults = q["defaults"]
con = db.connect()
owner = con.execute("SELECT id FROM users WHERE role='owner' LIMIT 1").fetchone()["id"]
lock = []
for i, item in enumerate(q["items"]):
prompt = f"{item['prompt']}. {styles[item['style']]}"
params = {
"prompt": prompt,
"model": defaults["model"],
"steps": defaults["steps"],
"width": item["w"],
"height": item["h"],
"seed": 7 + i, # per-asset fixed seed = reproducible
}
job_id = db.new_id()
outdir = runner.JOBS_DIR / job_id
outdir.mkdir(parents=True, exist_ok=True)
con.execute(
"INSERT INTO jobs (id, operator, status, asset_id, asset_ids, params, outdir, created_at, user_id) "
"VALUES (?, 'flux_local', 'queued', NULL, '[]', ?, ?, ?, ?)",
(job_id, json.dumps(params), str(outdir), db.now(), owner),
)
lock.append({"job_id": job_id, "name": item["name"], "seed": params["seed"]})
print(f"queued {item['name']:20s} {job_id}")
con.commit()
(HERE / "queue.lock.json").write_text(json.dumps(lock, indent=2))
print(f"\n{len(lock)} jobs queued. Restart MB to run: cd ~/MODELBEAST && scripts/serve.sh")