Alikestocode commited on
Commit
7a2a590
·
1 Parent(s): 4be72e0

Fix delete_revisions import with fallback cache cleanup

Browse files

- Handle missing delete_revisions function gracefully
- Add manual cache directory deletion as fallback
- Improve error handling for cache cleanup

Files changed (4) hide show
  1. Dockerfile +5 -1
  2. MANUAL_DEPLOY.md +54 -0
  3. QUICK_DEPLOY.md +0 -104
  4. test_space_simple.sh +48 -0
Dockerfile CHANGED
@@ -15,7 +15,11 @@ WORKDIR /app
15
  COPY requirements.txt .
16
 
17
  # Install Python dependencies
18
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
19
 
20
  # Copy application code
21
  COPY . .
 
15
  COPY requirements.txt .
16
 
17
  # Install Python dependencies
18
+ # Note: flash-attn requires CUDA for compilation, so skip it for CPU-only Cloud Run deployments
19
+ # The app gracefully handles missing flash-attn (see app.py FLASH_ATTN_AVAILABLE check)
20
+ RUN sed '/^flash-attn/d' requirements.txt > requirements-no-flash.txt && \
21
+ pip install --no-cache-dir -r requirements-no-flash.txt && \
22
+ echo "Installed dependencies (skipped flash-attn - requires CUDA)"
23
 
24
  # Copy application code
25
  COPY . .
MANUAL_DEPLOY.md ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Manual Deployment Steps (Cloud Console)
2
+
3
+ Since there are permission propagation issues, here's how to deploy manually via Cloud Console:
4
+
5
+ ## Step 1: Enable APIs via Cloud Console
6
+
7
+ 1. **Cloud Build API**: https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com?project=spherical-gate-477614-q7
8
+ - Click "Enable"
9
+
10
+ 2. **Cloud Run API**: https://console.cloud.google.com/apis/library/run.googleapis.com?project=spherical-gate-477614-q7
11
+ - Click "Enable"
12
+
13
+ 3. **Container Registry API**: https://console.cloud.google.com/apis/library/containerregistry.googleapis.com?project=spherical-gate-477614-q7
14
+ - Click "Enable"
15
+
16
+ ## Step 2: Create Cloud Build Trigger (Optional)
17
+
18
+ Or use Cloud Shell:
19
+
20
+ ```bash
21
+ # In Cloud Shell
22
+ cd Milestone-6/router-agent/zero-gpu-space
23
+ gcloud builds submit --tag gcr.io/spherical-gate-477614-q7/router-agent:latest .
24
+ ```
25
+
26
+ ## Step 3: Deploy to Cloud Run
27
+
28
+ After image is built:
29
+
30
+ ```bash
31
+ gcloud run deploy router-agent \
32
+ --image gcr.io/spherical-gate-477614-q7/router-agent:latest \
33
+ --platform managed \
34
+ --region us-central1 \
35
+ --allow-unauthenticated \
36
+ --port 7860 \
37
+ --memory 8Gi \
38
+ --cpu 4 \
39
+ --timeout 3600 \
40
+ --set-env-vars "GRADIO_SERVER_NAME=0.0.0.0,GRADIO_SERVER_PORT=7860"
41
+ ```
42
+
43
+ ## Alternative: Use Cloud Shell
44
+
45
+ Cloud Shell has proper permissions. Open:
46
+ https://shell.cloud.google.com/?project=spherical-gate-477614-q7
47
+
48
+ Then run:
49
+ ```bash
50
+ git clone https://github.com/ALikesToCode/CourseGPT-Pro-DSAI-Lab-Group-6.git
51
+ cd CourseGPT-Pro-DSAI-Lab-Group-6/Milestone-6/router-agent/zero-gpu-space
52
+ ./deploy-cloud-build.sh
53
+ ```
54
+
QUICK_DEPLOY.md DELETED
@@ -1,104 +0,0 @@
1
- # Quick Deploy to Google Cloud Run
2
-
3
- ## Current Status
4
-
5
- **Issue**: Permission denied on project `light-quest-475608-k7`
6
-
7
- ## Quick Fix Options
8
-
9
- ### Option 1: Fix Permissions (Recommended)
10
-
11
- 1. **Grant yourself permissions** on the existing project:
12
- - Visit: https://console.cloud.google.com/iam-admin/iam/project?project=light-quest-475608-k7
13
- - Add role: `Editor` or `Owner` to your account (`jameswilsonlearnsrocode@gmail.com`)
14
- - Wait 2-3 minutes for propagation
15
-
16
- 2. **Enable APIs**:
17
- ```bash
18
- gcloud services enable cloudbuild.googleapis.com run.googleapis.com containerregistry.googleapis.com --project=light-quest-475608-k7
19
- ```
20
-
21
- 3. **Deploy**:
22
- ```bash
23
- cd Milestone-6/router-agent/zero-gpu-space
24
- ./deploy-cloud-build.sh
25
- ```
26
-
27
- ### Option 2: Create New Project
28
-
29
- ```bash
30
- # Run setup helper
31
- ./setup-gcp-permissions.sh
32
-
33
- # Or manually:
34
- gcloud projects create router-agent-deploy --name="Router Agent Deployment"
35
- gcloud config set project router-agent-deploy
36
- gcloud services enable cloudbuild.googleapis.com run.googleapis.com containerregistry.googleapis.com
37
-
38
- # Then deploy
39
- ./deploy-cloud-build.sh
40
- ```
41
-
42
- ### Option 3: Use Different Account/Project
43
-
44
- If you have access to another project:
45
-
46
- ```bash
47
- export GCP_PROJECT_ID="your-other-project-id"
48
- gcloud config set project ${GCP_PROJECT_ID}
49
- ./deploy-cloud-build.sh
50
- ```
51
-
52
- ## Manual Deployment Steps
53
-
54
- If scripts don't work, deploy manually:
55
-
56
- ```bash
57
- # 1. Set project
58
- gcloud config set project YOUR_PROJECT_ID
59
-
60
- # 2. Enable APIs (if not already enabled)
61
- gcloud services enable cloudbuild.googleapis.com run.googleapis.com containerregistry.googleapis.com
62
-
63
- # 3. Submit build
64
- cd Milestone-6/router-agent/zero-gpu-space
65
- gcloud builds submit --config=cloudbuild.yaml .
66
-
67
- # 4. Or build and deploy separately
68
- gcloud builds submit --tag gcr.io/YOUR_PROJECT_ID/router-agent:latest .
69
- gcloud run deploy router-agent \
70
- --image gcr.io/YOUR_PROJECT_ID/router-agent:latest \
71
- --platform managed \
72
- --region us-central1 \
73
- --allow-unauthenticated \
74
- --port 7860 \
75
- --memory 8Gi \
76
- --cpu 4
77
- ```
78
-
79
- ## Required Permissions
80
-
81
- Your account needs these roles:
82
- - `roles/cloudbuild.builds.editor` - To build images
83
- - `roles/run.admin` - To deploy to Cloud Run
84
- - `roles/serviceusage.serviceUsageConsumer` - To enable APIs
85
- - `roles/storage.admin` - To push to Container Registry
86
-
87
- Or use `roles/editor` or `roles/owner` for full access.
88
-
89
- ## Troubleshooting
90
-
91
- **Permission Denied**:
92
- - Check IAM: https://console.cloud.google.com/iam-admin/iam
93
- - Ensure billing is enabled
94
- - Wait 2-3 minutes after granting permissions
95
-
96
- **API Not Enabled**:
97
- - Enable manually: https://console.cloud.google.com/apis/library
98
- - Or use: `gcloud services enable <api-name>`
99
-
100
- **Build Fails**:
101
- - Check logs: `gcloud builds list` then `gcloud builds log BUILD_ID`
102
- - Ensure Dockerfile is correct
103
- - Check requirements.txt for compatibility
104
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_space_simple.sh ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Simple test script for Hugging Face Space (no Python dependencies)
3
+
4
+ SPACE_URL="https://alovestocode-zerogpu-llm-inference.hf.space"
5
+
6
+ echo "=========================================="
7
+ echo "Testing Hugging Face Space: ZeroGPU"
8
+ echo "=========================================="
9
+ echo ""
10
+
11
+ echo "1. Checking Space accessibility..."
12
+ HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$SPACE_URL")
13
+ if [ "$HTTP_CODE" == "200" ]; then
14
+ echo " ✅ Space is accessible (HTTP $HTTP_CODE)"
15
+ else
16
+ echo " ❌ Space returned HTTP $HTTP_CODE"
17
+ exit 1
18
+ fi
19
+
20
+ echo ""
21
+ echo "2. Checking API info endpoint..."
22
+ API_INFO=$(curl -s "$SPACE_URL/api/info" 2>&1)
23
+ if echo "$API_INFO" | grep -q "api_name\|endpoints"; then
24
+ echo " ✅ API info endpoint accessible"
25
+ echo "$API_INFO" | python3 -m json.tool 2>/dev/null | head -20 || echo " (Raw response received)"
26
+ else
27
+ echo " ⚠️ API info response: $API_INFO"
28
+ fi
29
+
30
+ echo ""
31
+ echo "3. Checking Space status..."
32
+ STATUS=$(curl -s "https://huggingface.co/api/spaces/Alovestocode/ZeroGPU-LLM-Inference" 2>&1 | python3 -c "import sys, json; data=json.load(sys.stdin); print(data.get('runtime', {}).get('stage', 'UNKNOWN'))" 2>/dev/null || echo "UNKNOWN")
33
+ echo " Space Status: $STATUS"
34
+
35
+ echo ""
36
+ echo "=========================================="
37
+ if [ "$HTTP_CODE" == "200" ]; then
38
+ echo "✅ Basic connectivity test PASSED"
39
+ echo ""
40
+ echo "Space URL: $SPACE_URL"
41
+ echo "To test the API with Python, install gradio_client:"
42
+ echo " pip install gradio_client"
43
+ echo " python test_api_gradio_client.py"
44
+ else
45
+ echo "❌ Basic connectivity test FAILED"
46
+ fi
47
+ echo "=========================================="
48
+