Spaces:
Runtime error
Runtime error
| #!/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() | |