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