"""Render all promo scenes with Manim in parallel.""" import subprocess import sys from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path ROOT = Path(__file__).parent SCENES = [ ("transformer.py", "Transformer"), ("architecture.py", "Architecture"), ("continuous_batching.py", "ContinuousBatching"), ("paged_cache.py", "PrefixCache"), ("cta.py", "CTA"), ] def render(file_name, scene_name, quality="-qh"): script_path = ROOT / file_name media_dir = ROOT / "output" cmd = [ sys.executable, "-m", "manim", str(script_path), scene_name, quality, "--media_dir", str(media_dir), ] print(f"[{scene_name}] Rendering...") subprocess.run(cmd, check=True) print(f"[{scene_name}] Done → {media_dir / 'videos' / scene_name.lower()}.mp4") if __name__ == "__main__": quality = "-qh" # 1080p; use -l for draft, -4k for ultra if len(sys.argv) > 1: quality = sys.argv[1] max_workers = len(SCENES) with ThreadPoolExecutor(max_workers=max_workers) as pool: fut = {pool.submit(render, f, s, quality): s for f, s in SCENES} for f in as_completed(fut): exc = f.exception() if exc: print(f"[{fut[f]}] Failed: {exc}") print("All scenes rendered.")