Update app.py
Browse files
app.py
CHANGED
|
@@ -497,7 +497,7 @@ async def warmup_start(payload: Optional[Dict[str, Any]] = Body(None)):
|
|
| 497 |
# Lancer un nouveau thread
|
| 498 |
job_id = uuid.uuid4().hex[:8]
|
| 499 |
warmup_state["job_id"] = job_id
|
| 500 |
-
|
| 501 |
th.start()
|
| 502 |
|
| 503 |
return {"ok": True, "started": True, "total": len(models), "job_id": job_id}
|
|
@@ -520,8 +520,7 @@ def warmup_status():
|
|
| 520 |
|
| 521 |
@app.post("/warmup/stop", tags=["warmup"])
|
| 522 |
def warmup_stop_api():
|
| 523 |
-
"""
|
| 524 |
-
|
| 525 |
with warmup_lock:
|
| 526 |
running = bool(warmup_state.get("running"))
|
| 527 |
if running:
|
|
@@ -530,6 +529,7 @@ def warmup_stop_api():
|
|
| 530 |
return {"ok": True, "was_running": False}
|
| 531 |
# >>> B1_END warmup_routes
|
| 532 |
|
|
|
|
| 533 |
# >>> B2_BEGIN warmup_audit
|
| 534 |
def _hf_cache_dir() -> str:
|
| 535 |
return os.path.expanduser(os.getenv("HF_HOME", "/home/user/.cache/huggingface"))
|
|
|
|
| 497 |
# Lancer un nouveau thread
|
| 498 |
job_id = uuid.uuid4().hex[:8]
|
| 499 |
warmup_state["job_id"] = job_id
|
| 500 |
+
th = threading.Thread(target=_warmup_thread, args=(models,), daemon=True)
|
| 501 |
th.start()
|
| 502 |
|
| 503 |
return {"ok": True, "started": True, "total": len(models), "job_id": job_id}
|
|
|
|
| 520 |
|
| 521 |
@app.post("/warmup/stop", tags=["warmup"])
|
| 522 |
def warmup_stop_api():
|
| 523 |
+
"""Demande l'arrêt propre (on termine le modèle en cours puis on stoppe)."""
|
|
|
|
| 524 |
with warmup_lock:
|
| 525 |
running = bool(warmup_state.get("running"))
|
| 526 |
if running:
|
|
|
|
| 529 |
return {"ok": True, "was_running": False}
|
| 530 |
# >>> B1_END warmup_routes
|
| 531 |
|
| 532 |
+
|
| 533 |
# >>> B2_BEGIN warmup_audit
|
| 534 |
def _hf_cache_dir() -> str:
|
| 535 |
return os.path.expanduser(os.getenv("HF_HOME", "/home/user/.cache/huggingface"))
|