document-qa-system / deploy_to_hf.sh
Varun2007's picture
Production Document Question Answering (DQA) ready for Hugging Face Spaces
d3d09d6
Raw History Blame Contribute Delete
1.73 kB
#!/usr/bin/env bash
# Deploy to Hugging Face Spaces Automation Script
# Usage: ./deploy_to_hf.sh <hf_username>/<space_name>
set -e
if [ -z "$1" ]; then
echo "Usage: ./deploy_to_hf.sh <hf_username>/<space_name>"
echo "Example: ./deploy_to_hf.sh ramakrishna/document-qa"
exit 1
fi
SPACE_REPO="$1"
SPACE_URL="https://huggingface.co/spaces/$SPACE_REPO"
echo "=========================================================="
echo "Preparing deployment to Hugging Face Space: $SPACE_REPO"
echo "=========================================================="
# Check git
if ! command -v git &> /dev/null; then
echo "Error: git is not installed."
exit 1
fi
# Ensure git is initialized locally
if [ ! -d ".git" ]; then
echo "Initializing local git repository..."
git init
git branch -M main
fi
# Ensure sample documents exist
if [ ! -f "data/sample_financial_report.pdf" ]; then
echo "Generating sample documents..."
python3 create_sample_docs.py
fi
# Set remote
echo "Setting git remote 'space' -> $SPACE_URL.git"
git remote remove space 2>/dev/null || true
git remote add space "$SPACE_URL.git"
# Add files
echo "Staging files..."
git add app.py config.py ingest.py retrieve.py generate.py verify.py evaluate.py
git add create_sample_docs.py requirements.txt packages.txt README.md .gitignore
git add data/
git commit -m "Deploy Production Document QA system to Hugging Face Space" || true
echo "Pushing to Hugging Face Spaces (main branch)..."
git push -u space main
echo "=========================================================="
echo "Successfully pushed to Hugging Face Spaces!"
echo "View your live app at: $SPACE_URL"
echo "=========================================================="