atheletic-performance-analysis / test_deployment.py
akarsh999's picture
Upload 7 files
ab7e923 verified
Raw
History Blame Contribute Delete
4.03 kB
#!/usr/bin/env python3
"""
Test script to verify all dependencies are working before deployment
"""
def test_imports():
"""Test all required imports."""
print("πŸ§ͺ Testing imports...")
try:
import gradio as gr
print(f"βœ… Gradio {gr.__version__}")
except ImportError as e:
print(f"❌ Gradio import failed: {e}")
return False
try:
import cv2
print(f"βœ… OpenCV {cv2.__version__}")
except ImportError as e:
print(f"❌ OpenCV import failed: {e}")
return False
try:
import numpy as np
print(f"βœ… NumPy {np.__version__}")
except ImportError as e:
print(f"❌ NumPy import failed: {e}")
return False
try:
import mediapipe as mp
print(f"βœ… MediaPipe {mp.__version__}")
except ImportError as e:
print(f"❌ MediaPipe import failed: {e}")
return False
try:
import yt_dlp
print(f"βœ… yt-dlp {yt_dlp.version.__version__}")
except ImportError as e:
print(f"❌ yt-dlp import failed: {e}")
return False
try:
import pandas as pd
print(f"βœ… Pandas {pd.__version__}")
except ImportError as e:
print(f"❌ Pandas import failed: {e}")
return False
return True
def test_app_creation():
"""Test that the app can be created without errors."""
print("\nπŸ—οΈ Testing app creation...")
try:
from app import create_interface
app = create_interface()
print("βœ… App created successfully")
print("βœ… Gradio interface compatible")
return True
except TypeError as e:
if "unexpected keyword argument" in str(e):
print(f"❌ Gradio compatibility issue: {e}")
print("πŸ’‘ This usually means a Gradio component parameter is not supported")
else:
print(f"❌ Type error in app creation: {e}")
return False
except Exception as e:
print(f"❌ App creation failed: {e}")
return False
def test_mediapipe_initialization():
"""Test MediaPipe pose initialization."""
print("\nπŸ€– Testing MediaPipe pose initialization...")
try:
import mediapipe as mp
mp_pose = mp.solutions.pose
pose = mp_pose.Pose(
static_image_mode=False,
model_complexity=1,
enable_segmentation=False
)
pose.close()
print("βœ… MediaPipe pose initialized successfully")
return True
except Exception as e:
print(f"❌ MediaPipe pose initialization failed: {e}")
return False
def main():
print("πŸƒβ€β™‚οΈ Athletic Ability Analysis - Deployment Test")
print("=" * 50)
all_tests_passed = True
# Test imports
if not test_imports():
all_tests_passed = False
# Test MediaPipe initialization
if not test_mediapipe_initialization():
all_tests_passed = False
# Test app creation
if not test_app_creation():
all_tests_passed = False
print("\n" + "=" * 50)
if all_tests_passed:
print("πŸŽ‰ All tests passed! Ready for deployment.")
print("\nπŸ“‹ Deployment files verified:")
import os
files = ["app.py", "requirements.txt", "README.md"]
for file in files:
if os.path.exists(file):
print(f"βœ… {file}")
else:
print(f"❌ {file} missing")
print("\nπŸš€ You can now deploy to Hugging Face Spaces:")
print("1. Go to https://huggingface.co/spaces")
print("2. Create a new Space with SDK: Gradio")
print("3. Upload app.py, requirements.txt, and README.md")
print("4. Wait for automatic deployment")
else:
print("❌ Some tests failed. Please fix the issues before deployment.")
print("\nπŸ”§ Try running: pip install -r requirements.txt")
if __name__ == "__main__":
main()