#!/bin/bash
# DCU ENVIRONMENT Activation Script + Dependency Installation
# Run with bash `source activate-q3.sh`
# By KsuserKqy
# 2025-10-20

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
BOLD_RED='\033[1;31m'
NC='\033[0m'

if ! command -v conda &>/dev/null; then
    echo -e "[$RED x $NC] Conda not found. Please install Conda first."
    return 1 2>/dev/null || exit 1
fi

CONDA_BASE=$(conda info --base 2>/dev/null)
if [ -f "$CONDA_BASE/etc/profile.d/conda.sh" ]; then
    source "$CONDA_BASE/etc/profile.d/conda.sh"
    conda activate dcu-q3
    echo -e "[$GREEN √ $NC] Conda environment 'dcu-q3' activated."
else
    echo -e "[$RED x $NC] Could not find conda.sh for initialization."
    return 1 2>/dev/null || exit 1
fi

echo -e "[$YELLOW → $NC] Installing Python packages ..."
pip install https://download.sourcefind.cn:65024/file/4/pytorch/DAS1.6/torch-2.5.1+das.opt1.dtk25041-cp310-cp310-manylinux_2_28_x86_64.whl
pip install \
    modelscope \
    huggingface_hub \
    transformers==4.56.2 \
    numpy==1.26.4 \
    accelerate \
    fastapi \
    uvicorn \
    pydantic \
    psutil \
    -i https://pypi.tuna.tsinghua.edu.cn/simple
if [ $? -eq 0 ]; then
    echo -e "[$GREEN √ $NC] All Python packages installed successfully."
else
    echo -e "[$RED x $NC] Some packages failed to install."
fi

echo -e "[$GREEN √ $NC] Environment setup completed."
