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()