#!/usr/bin/env python3 """ Quick deployment script for Hugging Face Spaces """ import subprocess import sys import os def run_command(cmd): """Run a shell command and return the result.""" try: result = subprocess.run(cmd, shell=True, capture_output=True, text=True) if result.returncode == 0: return True, result.stdout else: return False, result.stderr except Exception as e: return False, str(e) def main(): print("๐Ÿƒโ€โ™‚๏ธ Athletic Ability Analysis - Hugging Face Spaces Deployment") print("=" * 70) # Check if we're in the right directory if not os.path.exists("app.py"): print("โŒ Error: app.py not found. Please run this script from the project root.") sys.exit(1) print("โœ… Found app.py") # Check if athletic_performance.py exists if not os.path.exists("athletic_performance.py"): print("โŒ Error: athletic_performance.py not found.") sys.exit(1) print("โœ… Found athletic_performance.py") # Check if requirements.txt exists if not os.path.exists("requirements.txt"): print("โŒ Error: requirements.txt not found.") sys.exit(1) print("โœ… Found requirements.txt") # Check if README.md has the HF header try: with open("README.md", "r") as f: content = f.read() if not content.startswith("---"): print("โŒ Error: README.md missing Hugging Face Spaces header") print("๐Ÿ’ก The README should start with YAML frontmatter for HF Spaces") sys.exit(1) except FileNotFoundError: print("โŒ Error: README.md not found.") sys.exit(1) print("โœ… README.md has correct HF Spaces format") # Run the comprehensive test print("\n๐Ÿ” Running comprehensive tests...") success, output = run_command("python test_deployment.py") if success: print("โœ… All dependency tests passed!") else: print("โŒ Dependency tests failed.") print("๐Ÿ”ง Try running: pip install -r requirements.txt") print("๐Ÿ“‹ Or run: python test_deployment.py for detailed output") sys.exit(1) print("\n๐ŸŽ‰ All dependencies are available!") print("\n๐Ÿ“‹ Deployment Checklist:") print("1. โœ… app.py - Main Gradio application") print("2. โœ… athletic_performance.py - Core analysis module") print("3. โœ… requirements.txt - Python dependencies") print("4. โœ… README.md - With HF Spaces header") print("5. โœ… Dependencies tested") print("\n๐Ÿš€ Ready for Hugging Face Spaces deployment!") print("\n๐Ÿ“– Deployment Instructions:") print("1. Go to https://huggingface.co/spaces") print("2. Click 'Create new Space'") print("3. Choose 'Gradio' as the SDK") print("4. Upload these files:") print(" - app.py") print(" - athletic_performance.py") print(" - requirements.txt") print(" - README.md") print("5. ๐Ÿ” IMPORTANT - Set up API Key Security:") print(" - Go to Space Settings") print(" - Add Secret: GEMINI_API_KEY = your_api_key") print(" - NEVER commit API keys to your repository!") print("6. Wait for automatic deployment") print("\n๐Ÿ”— Your Space will be available at:") print(" https://huggingface.co/spaces/YOUR_USERNAME/athletic-ability-analysis") # Offer to test locally test_local = input("\n๐Ÿงช Would you like to test the app locally first? (y/n): ") if test_local.lower() in ['y', 'yes']: print("\n๐Ÿš€ Starting local Gradio server...") print("๐Ÿ“ Note: This will open in your browser. Press Ctrl+C to stop.") try: from app import create_interface app = create_interface() app.launch(debug=True, share=False) except KeyboardInterrupt: print("\nโœ… Local testing stopped.") except Exception as e: print(f"\nโŒ Error running local test: {e}") print("\n๐ŸŽŠ Thank you for using Athletic Ability Analysis!") if __name__ == "__main__": main()