Fix linting and CI dependencies
Browse files
hopcroft_skill_classification_tool_competition/main.py
CHANGED
|
@@ -22,7 +22,7 @@ import os
|
|
| 22 |
import time
|
| 23 |
from typing import List
|
| 24 |
|
| 25 |
-
from fastapi import FastAPI, HTTPException,
|
| 26 |
from fastapi.responses import JSONResponse, RedirectResponse
|
| 27 |
import mlflow
|
| 28 |
from prometheus_client import (
|
|
@@ -135,20 +135,14 @@ async def monitor_requests(request: Request, call_next):
|
|
| 135 |
try:
|
| 136 |
response = await call_next(request)
|
| 137 |
status_code = response.status_code
|
| 138 |
-
REQUESTS_TOTAL.labels(
|
| 139 |
-
method=method, endpoint=endpoint, http_status=status_code
|
| 140 |
-
).inc()
|
| 141 |
return response
|
| 142 |
except Exception as e:
|
| 143 |
-
REQUESTS_TOTAL.labels(
|
| 144 |
-
method=method, endpoint=endpoint, http_status=500
|
| 145 |
-
).inc()
|
| 146 |
raise e
|
| 147 |
finally:
|
| 148 |
duration = time.time() - start_time
|
| 149 |
-
REQUEST_DURATION_SECONDS.labels(method=method, endpoint=endpoint).observe(
|
| 150 |
-
duration
|
| 151 |
-
)
|
| 152 |
IN_PROGRESS_REQUESTS.labels(method=method, endpoint=endpoint).dec()
|
| 153 |
|
| 154 |
|
|
|
|
| 22 |
import time
|
| 23 |
from typing import List
|
| 24 |
|
| 25 |
+
from fastapi import FastAPI, HTTPException, Request, Response, status
|
| 26 |
from fastapi.responses import JSONResponse, RedirectResponse
|
| 27 |
import mlflow
|
| 28 |
from prometheus_client import (
|
|
|
|
| 135 |
try:
|
| 136 |
response = await call_next(request)
|
| 137 |
status_code = response.status_code
|
| 138 |
+
REQUESTS_TOTAL.labels(method=method, endpoint=endpoint, http_status=status_code).inc()
|
|
|
|
|
|
|
| 139 |
return response
|
| 140 |
except Exception as e:
|
| 141 |
+
REQUESTS_TOTAL.labels(method=method, endpoint=endpoint, http_status=500).inc()
|
|
|
|
|
|
|
| 142 |
raise e
|
| 143 |
finally:
|
| 144 |
duration = time.time() - start_time
|
| 145 |
+
REQUEST_DURATION_SECONDS.labels(method=method, endpoint=endpoint).observe(duration)
|
|
|
|
|
|
|
| 146 |
IN_PROGRESS_REQUESTS.labels(method=method, endpoint=endpoint).dec()
|
| 147 |
|
| 148 |
|