#!/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()