feat: 예측 실패 원인 노출 + /health/models 진단 + restart-ci.bat
사금향님이 만난 409 'both chronos & lgbm failed' 에러가 원인을 안 보여줘서
디버깅 어려웠음. 세 군데 보강:
1. ensemble.py: 두 모델 다 실패 시 chronos/lgbm 각각의 실제 에러 원문
(type:message) 을 RuntimeError 메시지에 포함. predict.py 가 409 detail
로 그대로 노출하므로 브라우저에서 바로 원인 확인 가능. LGBM 가 None
반환 (체크포인트 없음) 인 경우도 'model checkpoint not found' 로 명시.
2. /health/models 엔드포인트 추가:
- chronos.ping() — lazy load 시도 + 디바이스/모델명 반환
- LGBM_MODEL_DIR 의 *.pkl 개수와 샘플 8개 파일명 반환. cold start
(체크포인트 0개) 면 'no_checkpoints' 상태로 알림.
3. restart-ci.bat 추가 — restart.bat 에서 pause 빼고 종료 코드로만 알리는
SSH 비대화형 친화 버전. 일반 사용은 그대로 restart.bat.
This commit is contained in:
@@ -132,3 +132,30 @@ def health_keys() -> dict[str, object]:
|
||||
"dart": dart_mod.ping(),
|
||||
# huggingface 는 모델 다운로드 시점에 확인 (별도 ping 호출 비용 회피)
|
||||
}
|
||||
|
||||
|
||||
@app.get("/health/models")
|
||||
def health_models() -> dict[str, object]:
|
||||
"""Chronos / LGBM 가용성 진단.
|
||||
|
||||
Chronos: lazy 로드 첫 호출이라 30초~수 분 걸릴 수 있음 (HuggingFace 다운로드).
|
||||
LGBM: 체크포인트 디렉토리 스캔 — retrain 안 돈 cold start 에선 비어있음.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
from app.models import chronos as chronos_mod
|
||||
|
||||
lgbm_dir = Path(os.environ.get("LGBM_MODEL_DIR", "/app/data/models"))
|
||||
lgbm_files: list[str] = []
|
||||
if lgbm_dir.exists():
|
||||
lgbm_files = sorted(p.name for p in lgbm_dir.glob("*.pkl"))
|
||||
|
||||
return {
|
||||
"chronos": chronos_mod.ping(),
|
||||
"lgbm": {
|
||||
"model_dir": str(lgbm_dir),
|
||||
"checkpoint_count": len(lgbm_files),
|
||||
"samples": lgbm_files[:8], # 너무 많으면 잘라서.
|
||||
"status": "ok" if lgbm_files else "no_checkpoints (cold start, run retrain_weekly)",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user