File size: 4,129 Bytes
fff13d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
128
129
130
131
132
133
134
#!/bin/bash

# NeuroAnim Hugging Face Spaces Deployment Script
# This script helps you deploy your application to HF Spaces

set -e

echo "πŸš€ NeuroAnim - Hugging Face Spaces Deployment"
echo "=============================================="
echo ""

# Check if git is initialized
if [ ! -d .git ]; then
    echo "❌ Error: Not a git repository. Please run 'git init' first."
    exit 1
fi

# Get HF Space details
echo "πŸ“ Please provide your Hugging Face Space details:"
echo ""
read -p "Enter your HF username: " HF_USERNAME
read -p "Enter your Space name (e.g., neuroanim): " SPACE_NAME

if [ -z "$HF_USERNAME" ] || [ -z "$SPACE_NAME" ]; then
    echo "❌ Error: Username and Space name are required."
    exit 1
fi

SPACE_URL="https://huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}"
echo ""
echo "πŸ“ Your Space URL will be: $SPACE_URL"
echo ""

# Check if remote already exists
if git remote get-url space &> /dev/null; then
    echo "⚠️  Remote 'space' already exists. Removing it..."
    git remote remove space
fi

# Add HF Space as remote
echo "πŸ”— Adding Hugging Face Space as git remote..."
git remote add space "https://huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}"

# Create deployment branch
echo "🌿 Creating deployment branch..."
git checkout -b hf-deploy 2>/dev/null || git checkout hf-deploy

# Copy HF-specific README
echo "πŸ“„ Preparing README for Hugging Face..."
cp README_HF.md README.md

# Stage deployment files
echo "πŸ“¦ Staging files for deployment..."
git add requirements.txt README.md app.py orchestrator.py pyproject.toml .gitignore
git add mcp_servers/ utils/ neuroanim/ manim_mcp/ 2>/dev/null || true

# Check if there are changes to commit
if git diff --staged --quiet; then
    echo "ℹ️  No changes to commit. Files may already be staged."
else
    # Commit changes
    echo "πŸ’Ύ Committing changes..."
    git commit -m "Deploy to Hugging Face Spaces

- Add requirements.txt for HF Spaces
- Add HF-specific README with YAML frontmatter
- Include all necessary source files and modules
"
fi

# Push to HF Space
echo ""
echo "πŸš€ Ready to push to Hugging Face Spaces!"
echo ""
echo "⚠️  IMPORTANT: Before pushing, make sure you have:"
echo "   1. Created the Space at: https://huggingface.co/spaces"
echo "   2. Added HUGGINGFACE_API_KEY in Space Settings β†’ Secrets"
echo ""
read -p "Have you completed the above steps? (y/n): " CONFIRM

if [ "$CONFIRM" != "y" ] && [ "$CONFIRM" != "Y" ]; then
    echo ""
    echo "πŸ“‹ Next steps:"
    echo "   1. Go to https://huggingface.co/spaces"
    echo "   2. Click 'Create new Space'"
    echo "   3. Set Space name to: $SPACE_NAME"
    echo "   4. Select SDK: Gradio"
    echo "   5. Go to Settings β†’ Variables and secrets"
    echo "   6. Add HUGGINGFACE_API_KEY secret"
    echo "   7. Run this script again"
    echo ""
    exit 0
fi

echo ""
echo "πŸš€ Pushing to Hugging Face Spaces..."
echo ""

# Push to HF Space
if git push space hf-deploy:main; then
    echo ""
    echo "βœ… Successfully deployed to Hugging Face Spaces!"
    echo ""
    echo "🌐 Your Space URL: $SPACE_URL"
    echo ""
    echo "πŸ“Š Next steps:"
    echo "   1. Visit your Space URL to see the build progress"
    echo "   2. Check the Logs tab for any errors"
    echo "   3. Wait 5-10 minutes for the first build"
    echo "   4. Test your animation generator!"
    echo ""
    echo "πŸ’‘ Tip: You can upgrade hardware in Settings if rendering is slow"
    echo ""
else
    echo ""
    echo "❌ Push failed. This might be because:"
    echo "   1. The Space doesn't exist yet - create it at https://huggingface.co/spaces"
    echo "   2. You need to authenticate with HF CLI: huggingface-cli login"
    echo "   3. The Space name or username is incorrect"
    echo ""
    echo "πŸ”§ To authenticate with Hugging Face:"
    echo "   pip install huggingface_hub"
    echo "   huggingface-cli login"
    echo ""
    exit 1
fi

# Return to original branch
echo "πŸ”„ Returning to main branch..."
git checkout main 2>/dev/null || git checkout master 2>/dev/null || true

echo ""
echo "✨ Deployment complete! Happy animating! 🎬"