File size: 1,733 Bytes
4c6c214
 
 
 
 
 
 
 
 
 
 
 
3972381
 
 
4c6c214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f2bb329
 
 
 
 
 
4c6c214
 
f2bb329
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
# PHLAM (CPU) -- Hugging Face Space (Docker SDK), CPU-only free tier.
FROM python:3.10-slim

RUN useradd -m -u 1000 user
USER user

ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    HF_HOME=/home/user/.cache/huggingface \
    PYTHONUNBUFFERED=1 \
    PORT=7860 \
    ESM_MODEL=facebook/esm2_t12_35M_UR50D \
    REFERENCE_DATA_DIR=/data/reference/ \
    IMGVR_DATA_DIR=/data/imgvr_inphared \
    MODELS_DATA_DIR=/data/models

WORKDIR /home/user/app

COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
 && pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu \
 && pip install --no-cache-dir -r requirements.txt

# Bake the ESM-2 weights into the image so the first request isn't a cold download.
RUN python -c "from transformers import AutoTokenizer, AutoModel; m='facebook/esm2_t12_35M_UR50D'; AutoTokenizer.from_pretrained(m); AutoModel.from_pretrained(m)"

# reference_min.index / reference_min.parquet are NOT baked in -- they arrive
# via hfmount at REFERENCE_DATA_DIR (mounted_drive/reference/reference/) when
# the Space runs.

COPY --chown=user . .

EXPOSE 7860

# --timeout 900: /analyze's synchronous path (ESM/PHLAM load, annotation
# retriever's first touch of reference_min.* on hfmount) can be slow on a
# cold start over a network-mounted bucket -- this is gunicorn's worker
# silence timeout, not a hard request cap; background jobs (neighbor
# search, synteny) run in threads and never block a worker at all, so they
# aren't bound by this regardless of how long the FAISS indexes take.
CMD ["gunicorn", "app:app", \
     "--workers", "1", "--threads", "4", "--worker-class", "gthread", \
     "--timeout", "900", "--bind", "0.0.0.0:7860"]