Spaces:
Runtime error
Runtime error
File size: 4,172 Bytes
82f6468 0fe4c49 82f6468 ab7e923 82f6468 ab7e923 82f6468 0fe4c49 82f6468 0fe4c49 82f6468 0fe4c49 82f6468 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | #!/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()
|