File size: 2,705 Bytes
6fe70f4 |
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 |
#!/bin/bash
# Sharp Web Interface - One-Click Launcher
# Double-click this file to start the Sharp web interface
# Change to the script's directory
cd "$(dirname "$0")"
ENV_NAME="sharp"
PYTHON_VERSION="3.13"
echo "======================================"
echo " Sharp 3D Prediction - Web Interface"
echo "======================================"
echo ""
# Check if conda is available
if ! command -v conda &> /dev/null; then
echo "β Conda is not installed or not in PATH."
echo ""
echo "Please install Miniconda or Anaconda first:"
echo " https://docs.conda.io/en/latest/miniconda.html"
echo ""
read -p "Press Enter to exit..."
exit 1
fi
# Initialize conda for this shell session
eval "$(conda shell.bash hook)"
# Check if the environment exists
if ! conda env list | grep -q "^${ENV_NAME} "; then
echo "π¦ Creating conda environment '${ENV_NAME}' with Python ${PYTHON_VERSION}..."
conda create -n "$ENV_NAME" python="$PYTHON_VERSION" -y
if [ $? -ne 0 ]; then
echo "β Failed to create conda environment."
read -p "Press Enter to exit..."
exit 1
fi
echo "β
Environment created."
echo ""
fi
# Activate the environment
echo "π Activating conda environment '${ENV_NAME}'..."
conda activate "$ENV_NAME"
if [ $? -ne 0 ]; then
echo "β Failed to activate conda environment."
read -p "Press Enter to exit..."
exit 1
fi
# Check if sharp is installed by trying to import it
echo "π Checking if dependencies are installed..."
if ! python -c "import sharp" 2>/dev/null; then
echo "π¦ Installing project dependencies (this may take a few minutes)..."
pip install -r requirements.txt
if [ $? -ne 0 ]; then
echo "β Failed to install requirements."
read -p "Press Enter to exit..."
exit 1
fi
echo "β
Dependencies installed."
echo ""
fi
# Check if web dependencies are installed
if ! python -c "import fastapi" 2>/dev/null; then
echo "π¦ Installing web interface dependencies..."
pip install -r src/sharp/web/requirements.txt
if [ $? -ne 0 ]; then
echo "β Failed to install web requirements."
read -p "Press Enter to exit..."
exit 1
fi
echo "β
Web dependencies installed."
echo ""
fi
echo "======================================"
echo "π Starting Sharp Web Interface..."
echo "======================================"
echo ""
echo "Open your browser and go to:"
echo ""
echo " π http://localhost:8000"
echo ""
echo "Press Ctrl+C to stop the server."
echo ""
# Start the web server
python src/sharp/web/app.py
# Keep terminal open if server stops unexpectedly
read -p "Press Enter to exit..."
|