CadenShokat commited on
Commit
60afeea
·
verified ·
1 Parent(s): 020a076

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -15
Dockerfile CHANGED
@@ -1,7 +1,6 @@
1
  FROM python:3.11-slim
2
 
3
  ENV HF_HOME=/app/hf_cache \
4
- HF_HUB_ENABLE_HF_TRANSFER=1 \
5
  PYTHONDONTWRITEBYTECODE=1 \
6
  PYTHONUNBUFFERED=1
7
 
@@ -13,21 +12,17 @@ RUN pip install --no-cache-dir -r requirements.txt
13
 
14
  RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
15
 
16
- RUN python - <<'PY'
17
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
18
- PRIMARY="cardiffnlp/twitter-roberta-base-sentiment-latest"
19
- FALLBACK="distilbert-base-uncased-finetuned-sst-2-english"
20
- print("Pre-caching:", PRIMARY)
21
- try:
22
- AutoTokenizer.from_pretrained(PRIMARY)
23
- AutoModelForSequenceClassification.from_pretrained(PRIMARY)
24
- print("Primary cached.")
25
- except Exception as e:
26
- print("Primary cache failed:", e)
27
- print("Caching fallback:", FALLBACK)
28
- AutoTokenizer.from_pretrained(FALLBACK)
29
- AutoModelForSequenceClassification.from_pretrained(FALLBACK)
30
- print("Fallback cached.")
31
  PY
32
 
33
  COPY app.py .
 
1
  FROM python:3.11-slim
2
 
3
  ENV HF_HOME=/app/hf_cache \
 
4
  PYTHONDONTWRITEBYTECODE=1 \
5
  PYTHONUNBUFFERED=1
6
 
 
12
 
13
  RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
14
 
15
+ RUN python - <<'PY' || true
16
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
17
+ PRIMARY="cardiffnlp/twitter-roberta-base-sentiment" # <- stable 3-class
18
+ FALLBACK="distilbert-base-uncased-finetuned-sst-2-english" # binary
19
+ for mid in (PRIMARY, FALLBACK):
20
+ try:
21
+ AutoTokenizer.from_pretrained(mid)
22
+ AutoModelForSequenceClassification.from_pretrained(mid)
23
+ print("Cached:", mid)
24
+ except Exception as e:
25
+ print("Cache failed for", mid, "->", e)
 
 
 
 
26
  PY
27
 
28
  COPY app.py .