textilindo-ai-assistant / update_hf_space.sh
harismlnaslm's picture
Switch to API server: Replace Gradio with Flask API endpoints
4669d04
#!/bin/bash
# Update Textilindo AI Assistant on Hugging Face Spaces
# This script will update your existing HF Space with the Docker fixes
set -e
SPACE_DIR="Textilindo"
REPO_URL="https://huggingface.co/spaces/harismlnaslm/Textilindo"
echo "πŸš€ Updating Textilindo AI Assistant on Hugging Face Spaces"
echo "Repository: $REPO_URL"
echo ""
# Check if the space directory already exists
if [ -d "$SPACE_DIR" ]; then
echo "πŸ“ Using existing repository: $SPACE_DIR"
cd "$SPACE_DIR"
# Pull latest changes
echo "πŸ“₯ Pulling latest changes..."
git pull origin main
else
echo "πŸ“₯ Cloning space repository..."
echo "⚠️ You'll need to use your Hugging Face access token as password"
echo " Get your token from: https://huggingface.co/settings/tokens"
echo ""
git clone "$REPO_URL"
cd "$SPACE_DIR"
fi
echo "πŸ“‹ Copying updated files to space repository..."
# Copy the fixed files
echo "βœ… Copying app_gradio.py (with Docker fixes)..."
cp ../app_gradio.py .
echo "βœ… Copying updated Dockerfile (points to app_gradio.py)..."
cp ../Dockerfile .
echo "βœ… Copying requirements.txt..."
cp ../requirements.txt .
echo "βœ… Copying README.md..."
cp ../README.md .
# Copy templates directory
if [ -d "../templates" ]; then
cp -r ../templates .
echo "βœ… Templates copied"
fi
# Copy configs directory
if [ -d "../configs" ]; then
cp -r ../configs .
echo "βœ… Configs copied"
fi
# Copy data directory (if exists)
if [ -d "../data" ]; then
cp -r ../data .
echo "βœ… Data copied"
fi
# Copy the deployment guide
if [ -f "../HF_SPACES_DEPLOYMENT.md" ]; then
cp ../HF_SPACES_DEPLOYMENT.md .
echo "βœ… Deployment guide copied"
fi
echo ""
echo "πŸ“ Files ready for deployment:"
ls -la
echo ""
echo "πŸ”§ Key fixes included:"
echo "βœ… Dockerfile now points to app_gradio.py"
echo "βœ… app_gradio.py has enhanced error handling"
echo "βœ… Process keep-alive mechanism added"
echo "βœ… Fallback interface for error recovery"
echo ""
echo "πŸš€ Ready to deploy! Run these commands:"
echo ""
echo "git add ."
echo "git commit -m 'Fix: Docker container stopping issue - Enhanced Gradio interface'"
echo "git push"
echo ""
echo "🌐 Your updated app will be available at: $REPO_URL"
echo ""
echo "πŸ“Š Monitor the deployment:"
echo "1. Go to: https://huggingface.co/spaces/harismlnaslm/Textilindo"
echo "2. Check the 'Logs' tab to see the build progress"
echo "3. Wait for the build to complete (usually 2-5 minutes)"
echo ""
echo "βœ… The container should now stay alive and serve your app properly!"