FABLESLIP commited on
Commit
c9dc548
·
verified ·
1 Parent(s): a701adb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -19,6 +19,7 @@ import threading
19
  # <<<< HUGINFACE PATCH: WARMUP IMPORTS START >>>>
20
  from typing import List
21
  from huggingface_hub import snapshot_download
 
22
 
23
  # <<<< HUGINFACE PATCH: WARMUP IMPORTS END >>>>
24
  import subprocess
@@ -29,7 +30,7 @@ import os
29
  import httpx
30
 
31
  print("[BOOT] Video Editor API starting…")
32
- from copy import deepcopy
33
  POINTER_URL = os.getenv("BACKEND_POINTER_URL", "").strip()
34
  FALLBACK_BASE = os.getenv("BACKEND_BASE_URL", "http://127.0.0.1:8765").strip()
35
  print(f"[BOOT] POINTER_URL={POINTER_URL or '(unset)'}")
@@ -577,9 +578,7 @@ def poster(vid: str):
577
  return FileResponse(str(p), media_type="image/jpeg")
578
  raise HTTPException(404, "Poster introuvable")
579
 
580
- # >>> B1_BEGIN warmup_routes
581
- from copy import deepcopy
582
-
583
  @app.post("/warmup/start", tags=["warmup"])
584
  async def warmup_start(payload: Optional[Dict[str, Any]] = Body(None)):
585
  """
@@ -590,20 +589,27 @@ async def warmup_start(payload: Optional[Dict[str, Any]] = Body(None)):
590
  # Nettoie un éventuel stop précédent pour permettre un nouveau run
591
  warmup_stop.clear()
592
 
593
- models = []
594
  if payload and isinstance(payload, dict):
595
  models = [str(x).strip() for x in (payload.get("models") or []) if str(x).strip()]
 
 
 
 
596
  if not models:
597
- # Correction douce de typos connues + dé-doublonnage
598
- fixups = {"stabilityai/sd-vae-ft-ms": "stabilityai/sd-vae-ft-mse"}
599
- models = [fixups.get(m, m) for m in models]
600
- seen = set()
601
- models = [m for m in models if not (m in seen or seen.add(m))]
602
 
 
 
 
 
 
603
 
 
604
  if not models:
605
  raise HTTPException(400, "Aucun modèle fourni (payload.models) et WARMUP_MODELS vide")
606
 
 
607
  with warmup_lock:
608
  if warmup_state.get("running"):
609
  return {"ok": False, "already_running": True, "status": deepcopy(warmup_state)}
 
19
  # <<<< HUGINFACE PATCH: WARMUP IMPORTS START >>>>
20
  from typing import List
21
  from huggingface_hub import snapshot_download
22
+ from copy import deepcopy
23
 
24
  # <<<< HUGINFACE PATCH: WARMUP IMPORTS END >>>>
25
  import subprocess
 
30
  import httpx
31
 
32
  print("[BOOT] Video Editor API starting…")
33
+ # Remove this line as it is redundant and already imported at the top of the file.
34
  POINTER_URL = os.getenv("BACKEND_POINTER_URL", "").strip()
35
  FALLBACK_BASE = os.getenv("BACKEND_BASE_URL", "http://127.0.0.1:8765").strip()
36
  print(f"[BOOT] POINTER_URL={POINTER_URL or '(unset)'}")
 
578
  return FileResponse(str(p), media_type="image/jpeg")
579
  raise HTTPException(404, "Poster introuvable")
580
 
581
+ # Remove redundant import and ensure imports are at the top of the file
 
 
582
  @app.post("/warmup/start", tags=["warmup"])
583
  async def warmup_start(payload: Optional[Dict[str, Any]] = Body(None)):
584
  """
 
589
  # Nettoie un éventuel stop précédent pour permettre un nouveau run
590
  warmup_stop.clear()
591
 
592
+ # 1) Prendre la liste fournie si présente
593
  if payload and isinstance(payload, dict):
594
  models = [str(x).strip() for x in (payload.get("models") or []) if str(x).strip()]
595
+ else:
596
+ models = []
597
+
598
+ # 2) Sinon charger la liste par défaut (depuis WARMUP_MODELS)
599
  if not models:
600
+ models = _default_model_list()
 
 
 
 
601
 
602
+ # 3) Normaliser (fix typos) + dédoublonner
603
+ fixups = {"stabilityai/sd-vae-ft-ms": "stabilityai/sd-vae-ft-mse"}
604
+ models = [fixups.get(m, m) for m in models]
605
+ seen = set()
606
+ models = [m for m in models if not (m in seen or seen.add(m))]
607
 
608
+ # 4) Encore vide ? -> 400
609
  if not models:
610
  raise HTTPException(400, "Aucun modèle fourni (payload.models) et WARMUP_MODELS vide")
611
 
612
+ # 5) Lancer le job
613
  with warmup_lock:
614
  if warmup_state.get("running"):
615
  return {"ok": False, "already_running": True, "status": deepcopy(warmup_state)}