Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 3,895 Bytes
61d29fc | 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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | #!/bin/bash
# Hugging Face Setup & Deployment Script
# Helps you login, manage datasets, and deploy to Spaces
set -e
echo "π€ Hugging Face Setup & Deployment"
echo "===================================="
echo ""
# Load environment variables
if [ -f .env ]; then
source .env
fi
# Check if HF_USERNAME is set
if [ -z "$HF_USERNAME" ]; then
echo "β HF_USERNAME not set in .env"
echo "Please add: HF_USERNAME=your_username"
exit 1
fi
echo "π€ Username: $HF_USERNAME"
echo ""
# Step 1: Login to Hugging Face
echo "π Step 1: Login to Hugging Face"
echo "================================"
echo ""
echo "You'll need a Hugging Face token with WRITE permission."
echo "Get one at: https://huggingface.co/settings/tokens"
echo ""
read -p "Press Enter to login (or Ctrl+C to cancel)..."
huggingface-cli login
echo ""
echo "β
Login successful!"
echo ""
# Step 2: Check existing datasets
echo "π Step 2: List Existing Datasets"
echo "=================================="
echo ""
echo "Checking for datasets under your account..."
echo ""
# List datasets
huggingface-cli repo list --type dataset || echo "No datasets found or error listing"
echo ""
# Step 3: Offer to delete datasets
echo "ποΈ Step 3: Delete Datasets (Optional)"
echo "======================================="
echo ""
read -p "Do you want to delete any datasets? (y/N): " delete_choice
if [[ "$delete_choice" =~ ^[Yy]$ ]]; then
echo ""
echo "To delete a dataset, use:"
echo " huggingface-cli repo delete --type dataset USERNAME/DATASET-NAME"
echo ""
read -p "Enter dataset name to delete (or press Enter to skip): " dataset_name
if [ -n "$dataset_name" ]; then
echo "Deleting dataset: $dataset_name"
huggingface-cli repo delete --type dataset "$dataset_name" --yes || echo "Failed to delete, skipping..."
fi
fi
echo ""
echo "β
Dataset management complete"
echo ""
# Step 4: Check required environment variables
echo "π§ Step 4: Verify Environment Variables"
echo "========================================"
echo ""
required_vars=("HF_USERNAME" "OPENAI_API_KEY")
missing_vars=()
for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
missing_vars+=("$var")
else
# Mask the value for security
masked="${!var:0:8}..."
echo "β
$var = $masked"
fi
done
if [ ${#missing_vars[@]} -gt 0 ]; then
echo ""
echo "β οΈ Missing environment variables in .env:"
for var in "${missing_vars[@]}"; do
echo " - $var"
done
echo ""
echo "Please add these to your .env file before deploying."
exit 1
fi
echo ""
echo "β
All required environment variables set"
echo ""
# Step 5: Deploy to Hugging Face Spaces
echo "π Step 5: Deploy to Hugging Face Spaces"
echo "========================================="
echo ""
echo "This will deploy all three apps to Hugging Face:"
echo " - Documentation (Docusaurus)"
echo " - Main Application (React)"
echo " - API Backend (FastAPI)"
echo ""
echo "Cost: ~\$22/month for CPU Basic hardware"
echo ""
read -p "Proceed with deployment? (y/N): " deploy_choice
if [[ "$deploy_choice" =~ ^[Yy]$ ]]; then
echo ""
echo "π Starting deployment..."
./deploy-huggingface.sh "$HF_USERNAME"
else
echo ""
echo "βΉοΈ Deployment skipped. To deploy later, run:"
echo " ./deploy-huggingface.sh"
fi
echo ""
echo "π Setup Complete!"
echo "=================="
echo ""
echo "Next Steps:"
echo "1. Go to: https://huggingface.co/spaces/$HF_USERNAME/open-navigator"
echo "2. Settings β Resource configuration β Select 'CPU Basic'"
echo "3. Settings β Variables and secrets β Add your API keys as secrets:"
echo " - OPENAI_API_KEY"
echo " - ANTHROPIC_API_KEY"
echo "4. Wait for build (~10-15 minutes)"
echo ""
echo "Your Space URL will be:"
echo "https://$HF_USERNAME-open-navigator.hf.space/"
echo ""
|