| # This script helps deploy your application to Hugging Face Spaces | |
| # Set your Hugging Face username and space name | |
| read -p "Enter your Hugging Face username: " HF_USERNAME | |
| read -p "Enter your Space name (e.g., swahili-content-generation): " SPACE_NAME | |
| # Check if git is installed | |
| if ! command -v git &> /dev/null; then | |
| echo "Git is not installed. Please install git and try again." | |
| exit 1 | |
| fi | |
| # Check if git-lfs is installed | |
| if ! command -v git-lfs &> /dev/null; then | |
| echo "Git LFS is not installed. Please install git-lfs and try again." | |
| echo "Visit https://git-lfs.github.com/ for installation instructions." | |
| exit 1 | |
| fi | |
| # Check if the repository exists | |
| if [ ! -d ".git" ]; then | |
| echo "Initializing git repository..." | |
| git init | |
| git lfs install | |
| fi | |
| # Set up Git LFS tracking for large files | |
| echo "Setting up Git LFS for large files..." | |
| git lfs track "data/pdfs/*.pdf" | |
| git lfs track "data/index/*.index" | |
| git add .gitattributes | |
| # Rename Dockerfile.spaces to Dockerfile for Hugging Face Spaces | |
| cp Dockerfile.spaces Dockerfile | |
| # Add all files to git | |
| git add . | |
| # Commit changes | |
| git commit -m "Prepare for Hugging Face Spaces deployment" | |
| # Add Hugging Face Spaces as a remote | |
| git remote add space https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME || git remote set-url space https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME | |
| # Push to Hugging Face Spaces | |
| echo "Pushing to Hugging Face Spaces..." | |
| git push --force space main | |
| echo "Deployment complete! Your application should be available at: https://huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME" | |
| echo "Note: It may take a few minutes for the Space to build and deploy." |