""" UGC Studio preflight check. Verifies system tools and reports which providers are configured, so you know exactly what the pipeline will use (and what will fall back) before spending. Usage: uv run python scripts/preflight.py """ import os import shutil import sys # Allow running from the repo root. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) from app.services.providers import registry # noqa: E402 def _ok(flag: bool) -> str: return "OK " if flag else "-- " def main() -> int: print("== System tools ==") ffmpeg = shutil.which("ffmpeg") or os.environ.get("IMAGEIO_FFMPEG_EXE") magick = shutil.which("magick") or shutil.which("convert") print(f"[{_ok(bool(ffmpeg))}] ffmpeg {ffmpeg or 'NOT FOUND'}") print(f"[{_ok(bool(magick))}] imagemagick {magick or 'NOT FOUND (optional)'}") print("\n== Avatar engines ==") for name in registry.avatar_provider_names(): p = registry.get_avatar_provider(name) configured = bool(p and p.is_configured()) print(f"[{_ok(configured)}] {name}") print("\n== B-roll engines ==") for name in registry.broll_provider_names(): if name == "stock": print(f"[{_ok(True)}] stock (Pexels/Pixabay key in config.toml)") continue p = registry.get_broll_provider(name) print(f"[{_ok(bool(p and p.is_configured()))}] {name}") print("\n== Image engines (generative avatar) ==") for name in registry.image_provider_names(): p = registry.get_image_provider(name) print(f"[{_ok(bool(p and p.is_configured()))}] {name}") print("\n== Lip-sync engines ==") for name in registry.lipsync_provider_names(): if name == "none": continue p = registry.get_lipsync_provider(name) print(f"[{_ok(bool(p and p.is_configured()))}] {name}") print("\n== Active selection (env/config) ==") av = registry.get_avatar_provider() br = registry.get_broll_provider() im = registry.get_image_provider() lp = registry.get_lipsync_provider() print(f" avatar : {getattr(av, 'name', None)} (configured={bool(av and av.is_configured())})") print(f" b-roll : {getattr(br, 'name', 'stock')} (configured={bool(br and br.is_configured())})") print(f" image : {getattr(im, 'name', None)} (configured={bool(im and im.is_configured())})") print(f" lipsync: {getattr(lp, 'name', 'none')} (configured={bool(lp and lp.is_configured())})") print( "\nTip: with no keys the studio still works in stock-fallback mode. " "Set UGC_AVATAR_PROVIDER=generative + GEMINI_API_KEY + FAL_KEY for the " "ultra-realistic path." ) return 0 if __name__ == "__main__": raise SystemExit(main())