cjell
commited on
Commit
·
8b6ec58
1
Parent(s):
08c7878
better health check
Browse files
app.py
CHANGED
|
@@ -46,30 +46,30 @@ def predict_nsfw(query: Query):
|
|
| 46 |
|
| 47 |
@app.get("/health")
|
| 48 |
def health_check():
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
|
| 75 |
return status
|
|
|
|
| 46 |
|
| 47 |
@app.get("/health")
|
| 48 |
def health_check():
|
| 49 |
+
|
| 50 |
+
status = {
|
| 51 |
+
"server": "running",
|
| 52 |
+
"models": {}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
models = {
|
| 56 |
+
"spam": ("valurank/distilroberta-spam-comments-detection", spam),
|
| 57 |
+
"toxic": ("s-nlp/roberta_toxicity_classifier", toxic),
|
| 58 |
+
"sentiment": ("nlptown/bert-base-multilingual-uncased-sentiment", sentiment),
|
| 59 |
+
"nsfw": ("michellejieli/NSFW_text_classifier", nsfw),
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
for key, (model_name, model_pipeline) in models.items():
|
| 63 |
+
try:
|
| 64 |
+
model_pipeline("test")
|
| 65 |
+
status["models"][key] = {
|
| 66 |
+
"model_name": model_name,
|
| 67 |
+
"status": "running"
|
| 68 |
+
}
|
| 69 |
+
except Exception as e:
|
| 70 |
+
status["models"][key] = {
|
| 71 |
+
"model_name": model_name,
|
| 72 |
+
"status": f"error: {str(e)}"
|
| 73 |
+
}
|
| 74 |
|
| 75 |
return status
|