File size: 3,791 Bytes
8cc9aef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
118
119
120
121
122
123
124
125
126
127
#!/bin/bash

# AI Doctor Deployment Script for Hugging Face Spaces
# This script helps set up and deploy the AI Doctor application

echo "πŸ₯ AI Doctor - Deployment Setup Script"
echo "======================================"

# Check if we're in the right directory
if [ ! -f "app.py" ]; then
    echo "❌ Error: app.py not found. Please run this script from the project root directory."
    exit 1
fi

# Function to check if command exists
command_exists() {
    command -v "$1" >/dev/null 2>&1
}

# Check prerequisites
echo "πŸ” Checking prerequisites..."

if ! command_exists python3; then
    echo "❌ Python 3 is required but not installed."
    exit 1
fi

if ! command_exists pip; then
    echo "❌ pip is required but not installed."
    exit 1
fi

echo "βœ… Prerequisites check passed"

# Create virtual environment (optional for local development)
if [ "$1" = "--local" ]; then
    echo "🐍 Setting up local development environment..."
    
    if [ ! -d "venv" ]; then
        python3 -m venv venv
        echo "βœ… Virtual environment created"
    fi
    
    # Activate virtual environment
    source venv/bin/activate
    echo "βœ… Virtual environment activated"
    
    # Install dependencies
    echo "πŸ“¦ Installing dependencies..."
    pip install -r requirements.txt
    echo "βœ… Dependencies installed"
    
    # Run the application
    echo "πŸš€ Starting AI Doctor locally..."
    python app.py
    
elif [ "$1" = "--test" ]; then
    echo "πŸ§ͺ Running tests and validation..."
    
    # Check if all required files exist
    required_files=("app.py" "requirements.txt" "README.md")
    
    for file in "${required_files[@]}"; do
        if [ ! -f "$file" ]; then
            echo "❌ Missing required file: $file"
            exit 1
        fi
    done
    
    echo "βœ… All required files present"
    
    # Validate Python syntax
    echo "πŸ” Validating Python syntax..."
    python3 -m py_compile app.py
    if [ $? -eq 0 ]; then
        echo "βœ… Python syntax is valid"
    else
        echo "❌ Python syntax errors found"
        exit 1
    fi
    
    # Check requirements format
    echo "πŸ” Validating requirements.txt..."
    pip install --dry-run -r requirements.txt > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        echo "βœ… Requirements.txt is valid"
    else
        echo "❌ Issues found in requirements.txt"
        exit 1
    fi
    
    echo "βœ… All tests passed! Ready for deployment."
    
elif [ "$1" = "--deploy" ]; then
    echo "πŸš€ Preparing for Hugging Face Spaces deployment..."
    
    # Create deployment checklist
    echo "πŸ“‹ Deployment Checklist:"
    echo "  1. βœ… Create Hugging Face account at https://huggingface.co"
    echo "  2. βœ… Go to https://huggingface.co/spaces"
    echo "  3. βœ… Click 'Create new Space'"
    echo "  4. βœ… Choose 'Gradio' as SDK"
    echo "  5. βœ… Upload these files:"
    echo "     - app.py (main application)"
    echo "     - requirements.txt (dependencies)"
    echo "     - README.md (documentation)"
    echo "     - .space (configuration - optional)"
    echo "  6. βœ… Set hardware to 'CPU Basic' or 'T4 Small GPU'"
    echo "  7. βœ… Make space public or private as needed"
    echo "  8. βœ… Click 'Create Space'"
    echo ""
    echo "πŸŽ‰ Your AI Doctor will be live at: https://huggingface.co/spaces/YOUR_USERNAME/ai-doctor"
    
else
    echo "Usage: $0 [--local|--test|--deploy]"
    echo ""
    echo "Options:"
    echo "  --local   Set up and run locally for development"
    echo "  --test    Run validation tests"
    echo "  --deploy  Show deployment instructions"
    echo ""
    echo "For Hugging Face Spaces deployment, run: $0 --deploy"
fi

echo ""
echo "πŸ₯ AI Doctor Setup Complete!"
echo "For questions or issues, check the README.md file."