# Deploying to Hugging Face Space This document explains how to deploy the `hf_space/` folder to Hugging Face Spaces. ## Quick Deploy ```bash # From the project root ./scripts/deploy_hf_space.sh ``` Or manually: ```bash git subtree push --prefix hf_space hf main ``` ## Workflow ### 1. Make Changes Locally - Edit files in `hf_space/` directory - Commit changes to your local `main` branch ### 2. Push to GitHub (Optional) ```bash git push origin main ``` ### 3. Deploy to Hugging Face Space ```bash # Using the helper script (recommended) ./scripts/deploy_hf_space.sh # Or manually git subtree push --prefix hf_space hf main ``` ## Important Notes - **Always deploy from `hf_space/` subdirectory**: The HF Space expects files at the root, not in a subfolder - **Use `git subtree`**: This ensures only `hf_space/` contents are pushed to HF - **Force push if needed**: If you need to overwrite (e.g., after major refactoring): ```bash git subtree split --prefix hf_space -b hf-temp git checkout hf/main git reset --hard hf-temp git push hf HEAD:main --force git checkout main git branch -D hf-temp ``` ## Troubleshooting ### If subtree push fails with "non-fast-forward" The HF remote has diverged. Use the force push workflow above. ### If HF Space shows old code 1. Check what's actually deployed: `git ls-tree -r --name-only hf/main` 2. Verify `app.py` is the new version: `git show hf/main:app.py | head -20` 3. If wrong, use the force push workflow above