| #!/bin/bash |
| |
| |
| |
| |
|
|
| set -e |
|
|
| |
| RED='\033[0;31m' |
| GREEN='\033[0;32m' |
| YELLOW='\033[1;33m' |
| BLUE='\033[0;34m' |
| NC='\033[0m' |
|
|
| clear |
|
|
| echo -e "${BLUE}" |
| echo "=========================================================================" |
| echo " 𧬠DRUG REPURPOSING AI SYSTEM" |
| echo " π Production API Startup (Linux/Mac)" |
| echo "=========================================================================" |
| echo -e "${NC}" |
| echo "" |
|
|
| |
| if ! command -v python3 &> /dev/null; then |
| echo -e "${RED}ERROR: Python 3 is not installed${NC}" |
| echo "Please install Python 3.10+ from https://www.python.org/" |
| exit 1 |
| fi |
|
|
| PYTHON_VERSION=$(python3 --version | awk '{print $2}') |
| echo "β
Python $PYTHON_VERSION found" |
| echo "" |
|
|
| |
| echo "[1/5] Setting up virtual environment..." |
| if [ -d "venv" ]; then |
| echo "β
Virtual environment already exists" |
| else |
| echo "Creating new virtual environment..." |
| python3 -m venv venv |
| if [ $? -ne 0 ]; then |
| echo -e "${RED}ERROR: Failed to create virtual environment${NC}" |
| exit 1 |
| fi |
| fi |
|
|
| source venv/bin/activate |
| if [ $? -ne 0 ]; then |
| echo -e "${RED}ERROR: Failed to activate virtual environment${NC}" |
| exit 1 |
| fi |
| echo "β
Virtual environment activated" |
| echo "" |
|
|
| |
| echo "[2/5] Upgrading pip and setuptools..." |
| python -m pip install --upgrade pip setuptools wheel -q 2>/dev/null |
| if [ $? -eq 0 ]; then |
| echo "β
pip upgraded" |
| else |
| echo "β οΈ pip upgrade had warnings (continuing...)" |
| fi |
| echo "" |
|
|
| |
| echo "[3/5] Installing dependencies from requirements.txt..." |
| if [ ! -f "requirements.txt" ]; then |
| echo -e "${RED}ERROR: requirements.txt not found${NC}" |
| exit 1 |
| fi |
|
|
| pip install -r requirements.txt -q 2>/dev/null |
| if [ $? -ne 0 ]; then |
| echo "β οΈ WARNING: Some dependencies failed to install" |
| echo "This may be normal if you're missing optional packages" |
| fi |
| echo "β
Base dependencies installed" |
| echo "" |
|
|
| |
| echo "[4/5] Installing specialized ML packages..." |
|
|
| echo " Installing DeepPurpose (AI predictor) from GitHub..." |
| pip install git+https://github.com/kexinhuang12345/DeepPurpose.git -q 2>/dev/null |
| if [ $? -eq 0 ]; then |
| echo " β
DeepPurpose installed" |
| else |
| echo " β οΈ WARNING: DeepPurpose installation failed" |
| echo " The API will still run but use local mock predictions" |
| echo " To use real AI predictions, install manually:" |
| echo " pip install git+https://github.com/kexinhuang12345/DeepPurpose.git" |
| fi |
|
|
| echo " Installing TDC (drug data) from GitHub..." |
| pip install git+https://github.com/Alantic/TDC.git -q 2>/dev/null |
| if [ $? -eq 0 ]; then |
| echo " β
TDC installed" |
| else |
| echo " βΉοΈ NOTE: TDC installation failed" |
| echo " API will use local fallback drug library (40+ FDA-approved drugs)" |
| fi |
| echo "" |
|
|
| |
| echo "[5/5] Checking system capabilities..." |
| if command -v nvidia-smi &> /dev/null; then |
| echo "β
NVIDIA GPU detected - CUDA acceleration will be used" |
| else |
| echo "βΉοΈ No NVIDIA GPU detected - running in CPU mode" |
| echo " (API will still work, predictions may be slower)" |
| fi |
| echo "" |
|
|
| |
| echo -e "${GREEN}=========================================================================${NC}" |
| echo -e "${GREEN}β
SETUP COMPLETE - STARTING API SERVER${NC}" |
| echo -e "${GREEN}=========================================================================${NC}" |
| echo "" |
| echo "π API DOCUMENTATION & ENDPOINTS:" |
| echo " β’ Interactive Swagger Docs: http://localhost:8000/docs" |
| echo " β’ Alternative ReDoc Docs: http://localhost:8000/redoc" |
| echo " β’ OpenAPI Schema: http://localhost:8000/openapi.json" |
| echo "" |
| echo "π MONITORING ENDPOINTS:" |
| echo " β’ Health Check: http://localhost:8000/health" |
| echo " β’ Model Status: http://localhost:8000/api/v1/model-status" |
| echo "" |
| echo "𧬠MAIN SCREENING ENDPOINT (POST):" |
| echo " β’ Virtual Screening: http://localhost:8000/api/v1/screen" |
| echo " Example request body:" |
| echo " {" |
| echo " \"disease_name\": \"Type 2 Diabetes\"," |
| echo " \"min_score\": 0.5," |
| echo " \"top_n_targets\": 10," |
| echo " \"known_drugs\": [\"Metformin\"]" |
| echo " }" |
| echo "" |
| echo "π ADDITIONAL ENDPOINTS (POST):" |
| echo " β’ Get Disease Targets: http://localhost:8000/api/v1/disease-targets" |
| echo " β’ Get Protein Sequences: http://localhost:8000/api/v1/protein-sequences" |
| echo " β’ Get Drug Library: http://localhost:8000/api/v1/drug-library" |
| echo "" |
| echo "βΉοΈ Press CTRL+C to stop the server" |
| echo -e "${GREEN}=========================================================================${NC}" |
| echo "" |
|
|
| |
| python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload |
|
|
| echo "" |
| } |
|
|
| echo "[4.75/5] Checking GPU availability..." |
| python -c "import torch; print(f'GPU Available: {torch.cuda.is_available()}')" 2>/dev/null || { |
| echo "GPU detection skipped (continue with CPU-only mode)" |
| } |
| echo "" |
|
|
| echo "[5/5] Starting API server..." |
| echo "" |
| echo "==============================================" |
| echo "β
Setup Complete! Starting API server..." |
| echo "==============================================" |
| echo "" |
| echo "API Endpoints:" |
| echo " Documentation: http://localhost:8000/docs" |
| echo " Health Check: http://localhost:8000/health" |
| echo " Model Status: http://localhost:8000/api/v1/model-status" |
| echo " Virtual Screen: http://localhost:8000/api/v1/screen" |
| echo "" |
| echo "Running Mode:" |
| echo " If DeepPurpose installed: PRODUCTION (Real AI predictions)" |
| echo " If DeepPurpose failed: MOCK (Simulated predictions)" |
| echo "" |
| echo "Check http://localhost:8000/api/v1/model-status for actual mode" |
| echo "" |
| echo "Press Ctrl+C to stop the server" |
| echo "" |
|
|
| uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 |
|
|