File size: 1,163 Bytes
05d11c3
5d26e96
a7965d0
05d11c3
323f857
ed1f849
 
 
 
5d26e96
 
 
a7965d0
05d11c3
 
 
323f857
a7965d0
05d11c3
323f857
a7965d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed1f849
 
a7965d0
05d11c3
 
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
FROM python:3.10-slim

# --- Configuraci贸n general y optimizaci贸n CPU ---
ENV HF_HUB_DISABLE_TELEMETRY=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    TOKENIZERS_PARALLELISM=false \
    OMP_NUM_THREADS=1 \
    MKL_NUM_THREADS=1

WORKDIR /app

# --- Dependencias ---
COPY requirements.txt .
RUN pip install --upgrade pip setuptools wheel \
 && pip install -r requirements.txt

# --- Copiamos el c贸digo y modelos ---
COPY . .

# --- Warmup: descarga y cachea modelos en build ---
RUN python - <<'PY'
import pickle
from transformers import pipeline
from sentence_transformers import SentenceTransformer

print("Warmup: inicializando modelos...")

# Sentimiento (siempre existe)
pipeline('text-classification', model='UMUTeam/roberta-spanish-sentiment-analysis', device=-1)('hola')

# SBERT (solo si predictor.pkl existe)
try:
    lw = pickle.load(open('predictor.pkl','rb'))
    SentenceTransformer(lw['model_name']).encode('hola')
    print("Warmup SBERT completo.")
except Exception as e:
    print("Warmup SBERT omitido:", e)
PY

# --- Exposici贸n del servicio ---
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]