Spaces:
Runtime error
Runtime error
# AI Doctor Deployment Script for Hugging Face Spaces | |
# This script helps set up and deploy the AI Doctor application | |
echo "π₯ AI Doctor - Deployment Setup Script" | |
echo "======================================" | |
# Check if we're in the right directory | |
if [ ! -f "app.py" ]; then | |
echo "β Error: app.py not found. Please run this script from the project root directory." | |
exit 1 | |
fi | |
# Function to check if command exists | |
command_exists() { | |
command -v "$1" >/dev/null 2>&1 | |
} | |
# Check prerequisites | |
echo "π Checking prerequisites..." | |
if ! command_exists python3; then | |
echo "β Python 3 is required but not installed." | |
exit 1 | |
fi | |
if ! command_exists pip; then | |
echo "β pip is required but not installed." | |
exit 1 | |
fi | |
echo "β Prerequisites check passed" | |
# Create virtual environment (optional for local development) | |
if [ "$1" = "--local" ]; then | |
echo "π Setting up local development environment..." | |
if [ ! -d "venv" ]; then | |
python3 -m venv venv | |
echo "β Virtual environment created" | |
fi | |
# Activate virtual environment | |
source venv/bin/activate | |
echo "β Virtual environment activated" | |
# Install dependencies | |
echo "π¦ Installing dependencies..." | |
pip install -r requirements.txt | |
echo "β Dependencies installed" | |
# Run the application | |
echo "π Starting AI Doctor locally..." | |
python app.py | |
elif [ "$1" = "--test" ]; then | |
echo "π§ͺ Running tests and validation..." | |
# Check if all required files exist | |
required_files=("app.py" "requirements.txt" "README.md") | |
for file in "${required_files[@]}"; do | |
if [ ! -f "$file" ]; then | |
echo "β Missing required file: $file" | |
exit 1 | |
fi | |
done | |
echo "β All required files present" | |
# Validate Python syntax | |
echo "π Validating Python syntax..." | |
python3 -m py_compile app.py | |
if [ $? -eq 0 ]; then | |
echo "β Python syntax is valid" | |
else | |
echo "β Python syntax errors found" | |
exit 1 | |
fi | |
# Check requirements format | |
echo "π Validating requirements.txt..." | |
pip install --dry-run -r requirements.txt > /dev/null 2>&1 | |
if [ $? -eq 0 ]; then | |
echo "β Requirements.txt is valid" | |
else | |
echo "β Issues found in requirements.txt" | |
exit 1 | |
fi | |
echo "β All tests passed! Ready for deployment." | |
elif [ "$1" = "--deploy" ]; then | |
echo "π Preparing for Hugging Face Spaces deployment..." | |
# Create deployment checklist | |
echo "π Deployment Checklist:" | |
echo " 1. β Create Hugging Face account at https://huggingface.co" | |
echo " 2. β Go to https://huggingface.co/spaces" | |
echo " 3. β Click 'Create new Space'" | |
echo " 4. β Choose 'Gradio' as SDK" | |
echo " 5. β Upload these files:" | |
echo " - app.py (main application)" | |
echo " - requirements.txt (dependencies)" | |
echo " - README.md (documentation)" | |
echo " - .space (configuration - optional)" | |
echo " 6. β Set hardware to 'CPU Basic' or 'T4 Small GPU'" | |
echo " 7. β Make space public or private as needed" | |
echo " 8. β Click 'Create Space'" | |
echo "" | |
echo "π Your AI Doctor will be live at: https://huggingface.co/spaces/YOUR_USERNAME/ai-doctor" | |
else | |
echo "Usage: $0 [--local|--test|--deploy]" | |
echo "" | |
echo "Options:" | |
echo " --local Set up and run locally for development" | |
echo " --test Run validation tests" | |
echo " --deploy Show deployment instructions" | |
echo "" | |
echo "For Hugging Face Spaces deployment, run: $0 --deploy" | |
fi | |
echo "" | |
echo "π₯ AI Doctor Setup Complete!" | |
echo "For questions or issues, check the README.md file." |