Spaces:
Sleeping
Sleeping
Commit History
-
section-8: FastAPI + Redis -- classify, detect, health, metrics endpoints
Priya Monisha- api/main.py: FastAPI lifespan (Rule 32), get_running_loop (Rule 31), non-blocking load_all_models via run_in_executor, eval_transform built once - api/routes/classify.py: POST /classify -- UploadFile+Form, Redis cache-aside, cached-key-pop fix (prevents TypeError on cache hit), Prometheus labels - api/routes/detect.py: POST /detect -- np.array(PIL) YOLO input, results[0].names, graceful 503 if YOLO unavailable - api/routes/health.py: GET /health -- 503 when loading (Docker healthcheck waits) - api/routes/metrics.py: GET /metrics -- CONTENT_TYPE_LATEST text/plain (Rule 30) - api/prometheus_metrics.py: Counter/Histogram singletons, class_name cardinality guard - api/schemas.py: ClassifyResponse, DetectResponse, HealthResponse Pydantic models - src/inference/model_loader.py: local-first weight resolution, HF Hub fallback with 120s ThreadPoolExecutor timeout, chunked MD5 hash, 3-pass warmup, FAST_MODE support - src/inference/redis_cache.py: socket_connect_timeout=1s (Rule 23), 32…9cb1db0