#!/bin/bash # 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."