Spaces:
Running
Running
Commit ·
c7440d4
1
Parent(s): 3b2f102
fix: add error handling in model loading and verification process
Browse files- infra/aws-serverless/Dockerfile.lambda +14 -10
- requirements.txt +2 -2
infra/aws-serverless/Dockerfile.lambda
CHANGED
|
@@ -52,17 +52,21 @@ ENV CACHE_DIR=${LAMBDA_TASK_ROOT}/model_cache
|
|
| 52 |
# Lambda. revision is always "main" — config.py's Settings has no
|
| 53 |
# separate revision field, so the champion is whatever's on main.
|
| 54 |
RUN python -c "\
|
| 55 |
-
import os, sys; \
|
| 56 |
sys.path.insert(0, os.environ['LAMBDA_TASK_ROOT']); \
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
ENV STORAGE_BACKEND=aws
|
| 68 |
ENV HF_HUB_OFFLINE=1
|
|
|
|
| 52 |
# Lambda. revision is always "main" — config.py's Settings has no
|
| 53 |
# separate revision field, so the champion is whatever's on main.
|
| 54 |
RUN python -c "\
|
| 55 |
+
import os, sys, traceback; \
|
| 56 |
sys.path.insert(0, os.environ['LAMBDA_TASK_ROOT']); \
|
| 57 |
+
try: \
|
| 58 |
+
from app.model.loader import load_model, verify_model; \
|
| 59 |
+
m = load_model( \
|
| 60 |
+
model_id=os.environ['MODEL_ID'], \
|
| 61 |
+
hf_token=os.environ.get('HF_TOKEN') or None, \
|
| 62 |
+
cache_dir=os.environ['CACHE_DIR'], \
|
| 63 |
+
revision='main', \
|
| 64 |
+
); \
|
| 65 |
+
verify_model(m); \
|
| 66 |
+
print('Baked and verified:', m.revision_tag); \
|
| 67 |
+
except Exception: \
|
| 68 |
+
traceback.print_exc(); \
|
| 69 |
+
sys.exit(1)"
|
| 70 |
|
| 71 |
ENV STORAGE_BACKEND=aws
|
| 72 |
ENV HF_HUB_OFFLINE=1
|
requirements.txt
CHANGED
|
@@ -8,9 +8,9 @@ pydantic-settings
|
|
| 8 |
# Model / inference
|
| 9 |
torch
|
| 10 |
torchaudio
|
| 11 |
-
transformers
|
|
|
|
| 12 |
speechbrain
|
| 13 |
-
huggingface_hub
|
| 14 |
av
|
| 15 |
numpy>=1.26,<2.2
|
| 16 |
soundfile
|
|
|
|
| 8 |
# Model / inference
|
| 9 |
torch
|
| 10 |
torchaudio
|
| 11 |
+
transformers>=4.30,<5
|
| 12 |
+
huggingface_hub>=0.20,<1
|
| 13 |
speechbrain
|
|
|
|
| 14 |
av
|
| 15 |
numpy>=1.26,<2.2
|
| 16 |
soundfile
|