File size: 2,587 Bytes
ea2b6ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# Git deployment script for Hugging Face Spaces
# This script adds, commits, and pushes all necessary files

echo "=== Preparing files for Hugging Face Spaces deployment ==="

# Step 1: Remove git lock file if exists
if [ -f .git/index.lock ]; then
    echo "Removing git lock file..."
    rm -f .git/index.lock
fi

# Step 2: Add core application files (required for API to work)
echo ""
echo "Adding core application files..."
git add app.py
git add preprocessing.py
git add model_utils.py
git add requirements.txt
git add Dockerfile

# Step 3: Add configuration files
echo "Adding configuration files..."
git add .dockerignore
git add .gitignore

# Step 4: Add documentation files
echo "Adding documentation files..."
git add README_HF_SPACE.md
git add DEPLOYMENT.md
git add DEPLOYMENT_SUMMARY.md
git add README.md

# Step 5: Add models directory (if exists and not in .gitignore)
if [ -d models ]; then
    echo "Checking models directory..."
    if ! grep -q "^models/" .gitignore 2>/dev/null; then
        echo "Adding models directory..."
        git add models/
    else
        echo "WARNING: models/ is in .gitignore. You may need to force add it:"
        echo "  git add -f models/"
    fi
fi

# Step 6: Show status
echo ""
echo "=== Files staged for commit ==="
git status --short

# Step 7: Commit
echo ""
echo "=== Committing changes ==="
git commit -m "Deploy to Hugging Face Spaces: Add application files and dependencies

- Add FastAPI application (app.py)
- Add preprocessing module (preprocessing.py)
- Add model utilities (model_utils.py)
- Add Dockerfile for HF Spaces deployment
- Add requirements.txt
- Add deployment documentation
- Add configuration files"

if [ $? -eq 0 ]; then
    echo ""
    echo "=== Commit successful! ==="
    
    # Step 8: Push
    echo ""
    echo "=== Pushing to remote ==="
    echo "Note: You may need to authenticate for push"
    git push
    
    if [ $? -eq 0 ]; then
        echo ""
        echo "=== Deployment files pushed successfully! ==="
        echo "Next steps:"
        echo "1. Go to your Hugging Face Space"
        echo "2. Wait for automatic rebuild"
        echo "3. Check logs if build fails"
    else
        echo ""
        echo "=== Push failed ==="
        echo "You may need to:"
        echo "1. Set up authentication (git credential or token)"
        echo "2. Check remote URL: git remote -v"
        echo "3. Try: git push origin main"
    fi
else
    echo ""
    echo "=== Commit failed ==="
    echo "Check git status and resolve any conflicts"
fi

echo ""
echo "=== Script completed ==="