Spaces:
Sleeping
Sleeping
File size: 2,634 Bytes
15fbd84 | 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 | #!/usr/bin/env bash
# ββ Deploy to HuggingFace Spaces βββββββββββββββββββββββββββββββββββββββββββββ
# Validates the file layout BEFORE pushing, because the most common failure is
# integrations/ never reaching the Space (the HF web uploader skips folders),
# which crashes startup with ModuleNotFoundError.
#
# Usage: ./deploy.sh <hf-username> <space-name>
# Example: ./deploy.sh plotweaver hausa-voice-agent
set -euo pipefail
USER="${1:-}"
SPACE="${2:-}"
if [[ -z "$USER" || -z "$SPACE" ]]; then
echo "Usage: ./deploy.sh <hf-username> <space-name>"
exit 1
fi
echo "ββ Validating layout βββββββββββββββββββββββββββββββββββββββββ"
REQUIRED=(
app.py pipeline.py nlu.py orchestrator.py vad.py streaming_asr.py
requirements.txt README.md
integrations/__init__.py integrations/crm.py
integrations/sip.py integrations/whatsapp.py
)
MISSING=0
for f in "${REQUIRED[@]}"; do
if [[ -f "$f" ]]; then
printf ' β %s\n' "$f"
else
printf ' β %s MISSING\n' "$f"
MISSING=1
fi
done
if [[ $MISSING -eq 1 ]]; then
echo ""
echo "Refusing to deploy: files are missing. The Space would crash on boot."
exit 1
fi
echo ""
echo "ββ Running tests βββββββββββββββββββββββββββββββββββββββββββββ"
python verify_boot.py || { echo "Boot check failed."; exit 1; }
python test_app.py || { echo "App launch test failed."; exit 1; }
python test_streaming.py || { echo "Streaming tests failed."; exit 1; }
python test_regressions.py || { echo "NLU tests failed."; exit 1; }
echo ""
echo "ββ Pushing to Space ββββββββββββββββββββββββββββββββββββββββββ"
if [[ ! -d .git ]]; then
git init -q
git remote add origin "https://huggingface.co/spaces/${USER}/${SPACE}"
fi
git add -A # -A, not '.', so nothing is quietly skipped
echo ""
echo "Staged files:"
git status --short
echo ""
read -r -p "Push these to ${USER}/${SPACE}? [y/N] " CONFIRM
[[ "$CONFIRM" == "y" || "$CONFIRM" == "Y" ]] || { echo "Aborted."; exit 0; }
git commit -q -m "Deploy Hausa Voice AI Agent" || echo "Nothing new to commit."
git push -u origin main
echo ""
echo "Done β https://huggingface.co/spaces/${USER}/${SPACE}"
echo "Set HF_TOKEN under Settings β Variables and secrets for best NLU quality."
|