"""Seed ~220 quick-finished jobs to check the feed at 200+ records (§五).""" import json import time import urllib.request BASE = "http://127.0.0.1:8247" def call(method, path, payload=None): data = json.dumps(payload).encode() if payload is not None else None req = urllib.request.Request( BASE + path, data=data, method=method, headers={"Content-Type": "application/json"} ) with urllib.request.urlopen(req, timeout=10) as r: body = r.read() return json.loads(body) if body else {} def main(): n0 = len(call("GET", "/api/playground/jobs")) target = 230 prompts = [ "雨后霓虹街道", "水墨山水长卷", "复古胶片人像", "微缩城市模型", "极光下的雪原", "蒸汽朋克飞行器", "油画风格的果园", "赛博废墟", ] for i in range(target - n0): call( "POST", "/api/playground/generate", { "workflow_id": 1, "input_values": {1: {"text": f"{prompts[i % len(prompts)]} #{i}"}, 2: i}, "source": "studio-image", }, ) time.sleep(0.15) # wait for the queue to drain for _ in range(600): jobs = call("GET", "/api/playground/jobs") active = [j for j in jobs if j["status"] in ("pending", "running")] if not active: print(f"done: {len(jobs)} jobs") return time.sleep(1) print("timeout waiting for drain") if __name__ == "__main__": main()