File size: 3,159 Bytes
71797a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Hugging Face Deployment Preparation Script
# This script prepares your app for deployment to Hugging Face Spaces

set -e  # Exit on error

echo "πŸš€ Preparing for Hugging Face Spaces Deployment"
echo "================================================"
echo ""

# Check if we're in the right directory
if [ ! -f "app_hf.py" ]; then
    echo "❌ Error: Must run from project root (where app_hf.py is located)"
    exit 1
fi

# Step 1: Copy HF-specific files
echo "πŸ“ Step 1: Copying HF-specific files..."
cp Dockerfile.hf Dockerfile
echo "   βœ“ Copied Dockerfile.hf β†’ Dockerfile"

cp README_HF.md README.md
echo "   βœ“ Copied README_HF.md β†’ README.md"

# Step 2: Verify required files exist
echo ""
echo "πŸ” Step 2: Verifying required files..."
required_files=("Dockerfile" "README.md" "requirements.txt" "app_hf.py" "wsgi.py" ".gitignore" "app/__init__.py")

for file in "${required_files[@]}"; do
    if [ -f "$file" ] || [ -d "$file" ]; then
        echo "   βœ“ $file"
    else
        echo "   ❌ Missing: $file"
        exit 1
    fi
done

# Step 3: Check app/ directory
echo ""
echo "πŸ“‚ Step 3: Checking app directory structure..."
app_dirs=("app/routes" "app/models" "app/templates" "app/fine_tuning")

for dir in "${app_dirs[@]}"; do
    if [ -d "$dir" ]; then
        echo "   βœ“ $dir/"
    else
        echo "   ⚠️  Warning: $dir/ not found"
    fi
done

# Step 4: Verify port configuration
echo ""
echo "πŸ”Œ Step 4: Verifying port 7860 configuration..."

if grep -q "7860" Dockerfile && grep -q "7860" app_hf.py; then
    echo "   βœ“ Port 7860 configured correctly"
else
    echo "   ❌ Port 7860 not found in Dockerfile or app_hf.py"
    exit 1
fi

# Step 5: Check for sensitive files
echo ""
echo "πŸ”’ Step 5: Checking for sensitive files..."

if [ -f ".env" ]; then
    echo "   ⚠️  WARNING: .env file exists - DO NOT upload to HF!"
    echo "      Use HF Secrets instead for FLASK_SECRET_KEY"
fi

if [ -f "instance/participatory_planner.db" ]; then
    echo "   ⚠️  Local database exists - will NOT be uploaded (good)"
fi

# Step 6: Generate deployment summary
echo ""
echo "πŸ“Š Step 6: Deployment Summary"
echo "============================="
echo ""
echo "Ready to deploy to Hugging Face Spaces!"
echo ""
echo "πŸ“¦ Files ready for upload:"
echo "   - Dockerfile (HF version)"
echo "   - README.md (with YAML header)"
echo "   - requirements.txt"
echo "   - app_hf.py"
echo "   - wsgi.py"
echo "   - app/ directory"
echo "   - .gitignore"
echo ""
echo "πŸ” IMPORTANT - Configure these secrets in HF Space Settings:"
echo "   Secret Name: FLASK_SECRET_KEY"
echo "   Secret Value: 9fd11d101e36efbd3a7893f56d604b860403d247633547586c41453118e69b00"
echo ""
echo "🌐 Next steps:"
echo "   1. Go to https://huggingface.co/new-space"
echo "   2. Choose SDK: Docker"
echo "   3. Upload the files listed above"
echo "   4. Add FLASK_SECRET_KEY to Secrets"
echo "   5. Wait for build (~10 minutes first time)"
echo ""
echo "πŸ“– For detailed instructions, see:"
echo "   - HF_DEPLOYMENT_CHECKLIST.md"
echo "   - HUGGINGFACE_DEPLOYMENT.md"
echo ""
echo "βœ… Preparation complete! Ready to deploy! πŸŽ‰"