Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 11 additions & 45 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,69 +1,35 @@
# BioAnalyzer Backend Dockerfile
FROM python:3.11-slim

WORKDIR /app

# FIX: Make Python recognize the application as a package
ENV PYTHONPATH="/app:/app/app"

# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
curl \
git \
gcc g++ curl git \
&& rm -rf /var/lib/apt/lists/*

# Copy pyproject.toml and README.md first for better caching
COPY pyproject.toml README.md ./

# Upgrade pip and setuptools first
RUN pip install --upgrade pip setuptools wheel build

# ------------------------------------------------------------
# Step 1: Install PyTorch CPU versions (fixed +cpu issue)
# Note: PyTorch CPU versions require special index URL, so we install them separately
# before installing the package from pyproject.toml
# ------------------------------------------------------------
RUN pip install --no-cache-dir --default-timeout=600 --retries=10 \
--extra-index-url https://download.pytorch.org/whl/cpu \
torch==2.1.0+cpu \
torchvision==0.16.0+cpu \
torchaudio==2.1.0+cpu
# Install PyTorch CPU wheels
RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu \
torch==2.1.0+cpu torchvision==0.16.0+cpu torchaudio==2.1.0+cpu

# ------------------------------------------------------------
# Step 2: Copy application code
# ------------------------------------------------------------
COPY . .

# ------------------------------------------------------------
# Step 3: Install the package from pyproject.toml
# This installs the package and all its dependencies from pyproject.toml
# PyTorch is already installed above, so pip will skip it
# Installing in editable mode (-e) ensures entry points are properly installed
# ------------------------------------------------------------
RUN pip install --no-cache-dir --default-timeout=300 --retries=5 -e .
# Install package + dependencies
RUN pip install --no-cache-dir -e .

# ------------------------------------------------------------
# Step 4: Install testing dependencies (optional, for development)
# ------------------------------------------------------------
RUN pip install --no-cache-dir pytest>=7.4.0 pytest-cov>=4.1.0
# Explicit analysis deps (defensive)
RUN pip install --no-cache-dir pandas scikit-learn matplotlib seaborn

# Create necessary directories
RUN mkdir -p cache logs results

# Make CLI executable
RUN chmod +x cli.py
RUN chmod +x cli.py || true
RUN chmod +x scripts/*.py || true

# Expose port
EXPOSE 8000

# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1

# Set PYTHONPATH for app module imports (fixed nested /app/app issue)
# ENV PYTHONPATH=/app:/app/app
HEALTHCHECK CMD curl -f http://localhost:8000/health || exit 1

# Default command (can be overridden)
CMD ["python", "main.py", "--host", "0.0.0.0", "--port", "8000"]
10 changes: 9 additions & 1 deletion app/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ def load_dotenv(*args: object, **kwargs: object) -> None: # type: ignore[no-red
)


import google.generativeai as genai
def get_genai():
try:
import google.generativeai as genai
return genai
except ImportError:
raise RuntimeError(
"google-generativeai is not installed. "
"Install with: pip install google-generativeai"
)

possible_env_paths = [
Path(__file__).parents[1] / ".env", # Original location
Expand Down
16 changes: 6 additions & 10 deletions config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ torchaudio>=2.1.0+cpu
numpy>=1.26.0
pandas>=2.1.1
scikit-learn>=1.3.0
matplotlib>=3.7
seaborn>=0.12
matplotlib>=3.7.0
seaborn>=0.12.0
biopython>=1.81
pytz>=2023.3

Expand All @@ -29,7 +29,7 @@ paper-qa>=5.0.0
# --- Vector Database ---
qdrant-client>=1.7.0

# --- Web Framework & API (FastAPI/Uvicorn) ---
# --- Web Framework & API ---
fastapi>=0.104.0
uvicorn[standard]>=0.23.2
starlette>=0.31.1
Expand All @@ -47,19 +47,15 @@ wsproto>=1.0.0
h11>=0.12.0
httptools>=0.3.0

# --- File Processing (Excel/Env) ---
# --- File Processing ---
openpyxl>=3.1.0
xlrd>=2.0.1
python-dotenv>=1.0.0
PyYAML>=5.4.1
aiofiles>=0.7.0

# --- Utilities & System ---
tqdm>=4.65.0`
# --- Utilities ---
tqdm>=4.65.0
psutil>=5.9.0
click>=8.0.1
watchfiles[watchdog]>=1.0.0

# --- Development (Uncomment to install) ---
# pytest>=7.4.0
# pytest-cov>=4.1.0
Loading
Loading