riteshkokam commited on
Commit
8cc9aef
Β·
verified Β·
1 Parent(s): 2d7b636

Create deploy.sh

Browse files
Files changed (1) hide show
  1. deploy.sh +127 -0
deploy.sh ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # AI Doctor Deployment Script for Hugging Face Spaces
4
+ # This script helps set up and deploy the AI Doctor application
5
+
6
+ echo "πŸ₯ AI Doctor - Deployment Setup Script"
7
+ echo "======================================"
8
+
9
+ # Check if we're in the right directory
10
+ if [ ! -f "app.py" ]; then
11
+ echo "❌ Error: app.py not found. Please run this script from the project root directory."
12
+ exit 1
13
+ fi
14
+
15
+ # Function to check if command exists
16
+ command_exists() {
17
+ command -v "$1" >/dev/null 2>&1
18
+ }
19
+
20
+ # Check prerequisites
21
+ echo "πŸ” Checking prerequisites..."
22
+
23
+ if ! command_exists python3; then
24
+ echo "❌ Python 3 is required but not installed."
25
+ exit 1
26
+ fi
27
+
28
+ if ! command_exists pip; then
29
+ echo "❌ pip is required but not installed."
30
+ exit 1
31
+ fi
32
+
33
+ echo "βœ… Prerequisites check passed"
34
+
35
+ # Create virtual environment (optional for local development)
36
+ if [ "$1" = "--local" ]; then
37
+ echo "🐍 Setting up local development environment..."
38
+
39
+ if [ ! -d "venv" ]; then
40
+ python3 -m venv venv
41
+ echo "βœ… Virtual environment created"
42
+ fi
43
+
44
+ # Activate virtual environment
45
+ source venv/bin/activate
46
+ echo "βœ… Virtual environment activated"
47
+
48
+ # Install dependencies
49
+ echo "πŸ“¦ Installing dependencies..."
50
+ pip install -r requirements.txt
51
+ echo "βœ… Dependencies installed"
52
+
53
+ # Run the application
54
+ echo "πŸš€ Starting AI Doctor locally..."
55
+ python app.py
56
+
57
+ elif [ "$1" = "--test" ]; then
58
+ echo "πŸ§ͺ Running tests and validation..."
59
+
60
+ # Check if all required files exist
61
+ required_files=("app.py" "requirements.txt" "README.md")
62
+
63
+ for file in "${required_files[@]}"; do
64
+ if [ ! -f "$file" ]; then
65
+ echo "❌ Missing required file: $file"
66
+ exit 1
67
+ fi
68
+ done
69
+
70
+ echo "βœ… All required files present"
71
+
72
+ # Validate Python syntax
73
+ echo "πŸ” Validating Python syntax..."
74
+ python3 -m py_compile app.py
75
+ if [ $? -eq 0 ]; then
76
+ echo "βœ… Python syntax is valid"
77
+ else
78
+ echo "❌ Python syntax errors found"
79
+ exit 1
80
+ fi
81
+
82
+ # Check requirements format
83
+ echo "πŸ” Validating requirements.txt..."
84
+ pip install --dry-run -r requirements.txt > /dev/null 2>&1
85
+ if [ $? -eq 0 ]; then
86
+ echo "βœ… Requirements.txt is valid"
87
+ else
88
+ echo "❌ Issues found in requirements.txt"
89
+ exit 1
90
+ fi
91
+
92
+ echo "βœ… All tests passed! Ready for deployment."
93
+
94
+ elif [ "$1" = "--deploy" ]; then
95
+ echo "πŸš€ Preparing for Hugging Face Spaces deployment..."
96
+
97
+ # Create deployment checklist
98
+ echo "πŸ“‹ Deployment Checklist:"
99
+ echo " 1. βœ… Create Hugging Face account at https://huggingface.co"
100
+ echo " 2. βœ… Go to https://huggingface.co/spaces"
101
+ echo " 3. βœ… Click 'Create new Space'"
102
+ echo " 4. βœ… Choose 'Gradio' as SDK"
103
+ echo " 5. βœ… Upload these files:"
104
+ echo " - app.py (main application)"
105
+ echo " - requirements.txt (dependencies)"
106
+ echo " - README.md (documentation)"
107
+ echo " - .space (configuration - optional)"
108
+ echo " 6. βœ… Set hardware to 'CPU Basic' or 'T4 Small GPU'"
109
+ echo " 7. βœ… Make space public or private as needed"
110
+ echo " 8. βœ… Click 'Create Space'"
111
+ echo ""
112
+ echo "πŸŽ‰ Your AI Doctor will be live at: https://huggingface.co/spaces/YOUR_USERNAME/ai-doctor"
113
+
114
+ else
115
+ echo "Usage: $0 [--local|--test|--deploy]"
116
+ echo ""
117
+ echo "Options:"
118
+ echo " --local Set up and run locally for development"
119
+ echo " --test Run validation tests"
120
+ echo " --deploy Show deployment instructions"
121
+ echo ""
122
+ echo "For Hugging Face Spaces deployment, run: $0 --deploy"
123
+ fi
124
+
125
+ echo ""
126
+ echo "πŸ₯ AI Doctor Setup Complete!"
127
+ echo "For questions or issues, check the README.md file."