"""Materialize portable test manifests as inference and rendering jobs.""" import argparse import json from pathlib import Path import os ROOT = Path(os.environ.get("ELLSA2_DATA_ROOT", Path(__file__).resolve().parents[1])).expanduser().resolve() def read_manifest(): return [json.loads(s) for s in (ROOT / "testset/manifest.jsonl").read_text().splitlines() if s] def prepare(output_dir, test_id=None, limit=0): output_dir = Path(output_dir).resolve() output_dir.mkdir(parents=True, exist_ok=True) rows = read_manifest() if test_id: rows = [r for r in rows if r["group_id"] == test_id] assert rows, f"Unknown test id: {test_id}" rows = rows[:limit or None] jobs = [] render = [] for r in rows: gid = r["group_id"] motion = output_dir / (gid + ".npz") jobs.append({"group_id": gid, "audio_file": str(ROOT / r["audio20_target"]), "audio_file_listen": str(ROOT / r["audio20_partner"]), "word_file": str(ROOT / r["metadata20_target"]), "word_file_listen": str(ROOT / r["metadata20_partner"]), "motion_style_pose_path": str(ROOT / r["motion_style_pose_path"]), "motion_style_flame_path": str(ROOT / r["motion_style_flame_path"]) if r.get("motion_style_flame_path") else "", "motion_style_start": 0, "motion_style_length": 612, "output_path": str(motion), "sampling_seed": 0}) render.append({"group_id": gid, "system_id": "ELLSA2", "npz_path": str(motion), "wav_path": str(ROOT / r["audio20_target"]), "video_path": str(output_dir / "videos" / (gid + ".mp4")), "ready_path": str(output_dir / "render_ready" / (gid + ".ready")), "tmp_dir": str(output_dir / "render_tmp" / gid)}) job_file = output_dir / "inference_jobs.json" job_file.write_text(json.dumps({"data": jobs}, indent=2)) (output_dir / "render_jobs.json").write_text(json.dumps(render, indent=2)) return job_file def main(): p = argparse.ArgumentParser() p.add_argument("--output-dir", default="outputs/test") p.add_argument("--test-id") p.add_argument("--limit", type=int, default=0) args = p.parse_args() print(prepare(args.output_dir, args.test_id, args.limit)) if __name__ == "__main__": main()