akarsh999's picture
Upload 9 files
0fe4c49 verified
Raw
History Blame Contribute Delete
4.17 kB
#!/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()