Video-generator / test_deployment.py
parthraninga's picture
Upload 8 files
1dfc9df verified
raw
history blame
2.07 kB
#!/usr/bin/env python3
"""
Test script to verify the video generator works locally before deployment
"""
import os
import sys
from pathlib import Path
def test_imports():
"""Test if all required packages can be imported"""
try:
import gradio as gr
print("βœ… Gradio imported successfully")
import google.generativeai as genai
print("βœ… Google Generative AI imported successfully")
import manim
print("βœ… Manim imported successfully")
import numpy
print("βœ… NumPy imported successfully")
return True
except ImportError as e:
print(f"❌ Import error: {e}")
return False
def test_api_key():
"""Test if API key is available"""
api_key = os.getenv("GEMINI_API_KEY")
if api_key:
print("βœ… GEMINI_API_KEY found")
return True
else:
print("⚠️ GEMINI_API_KEY not found - set it in environment variables")
return False
def test_manim():
"""Test if Manim can run a simple scene"""
try:
from manim import Scene, Text, FadeIn
print("βœ… Manim core classes imported successfully")
return True
except Exception as e:
print(f"❌ Manim test failed: {e}")
return False
def main():
"""Run all tests"""
print("πŸ§ͺ Running pre-deployment tests...\n")
all_tests = [
("Import Test", test_imports),
("API Key Test", test_api_key),
("Manim Test", test_manim),
]
results = []
for test_name, test_func in all_tests:
print(f"Running {test_name}...")
result = test_func()
results.append(result)
print()
if all(results):
print("πŸŽ‰ All tests passed! Ready for deployment to Hugging Face Spaces")
return 0
else:
print("❌ Some tests failed. Please fix the issues before deployment")
return 1
if __name__ == "__main__":
sys.exit(main())