Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
|
@@ -929,62 +929,62 @@ DEFAULT_WITH_MODEL_NAME = True
|
|
| 929 |
# Singleton Upscale instance for API
|
| 930 |
_api_upscale = Upscale()
|
| 931 |
|
| 932 |
-
# @fastapi_app.get("/health")
|
| 933 |
-
# def health(_: bool = Depends(_verify_bearer_token)):
|
| 934 |
-
# return {"status": "ok"}
|
| 935 |
@fastapi_app.get("/health")
|
| 936 |
-
|
| 937 |
-
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
|
| 941 |
-
|
| 942 |
-
|
| 943 |
-
|
| 944 |
-
|
| 945 |
-
|
|
|
|
|
|
|
|
|
|
| 946 |
|
| 947 |
-
|
| 948 |
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
-
|
| 963 |
-
|
| 964 |
|
| 965 |
-
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
|
| 972 |
|
| 973 |
-
|
| 974 |
-
|
| 975 |
|
| 976 |
-
|
| 977 |
-
|
| 978 |
-
|
| 979 |
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
|
| 986 |
-
|
| 987 |
-
|
| 988 |
@fastapi_app.get("/source")
|
| 989 |
def source(_: bool = Depends(_verify_bearer_token)):
|
| 990 |
return {
|
|
|
|
| 929 |
# Singleton Upscale instance for API
|
| 930 |
_api_upscale = Upscale()
|
| 931 |
|
|
|
|
|
|
|
|
|
|
| 932 |
@fastapi_app.get("/health")
|
| 933 |
+
def health(_: bool = Depends(_verify_bearer_token)):
|
| 934 |
+
return {"status": "ok"}
|
| 935 |
+
# @fastapi_app.get("/health")
|
| 936 |
+
# async def health(_: bool = Depends(_verify_bearer_token)):
|
| 937 |
+
# checks = {
|
| 938 |
+
# "api": "ok",
|
| 939 |
+
# "gpu": "unknown",
|
| 940 |
+
# "torch": "unknown",
|
| 941 |
+
# "disk": "unknown",
|
| 942 |
+
# "mongo": "skipped",
|
| 943 |
+
# "weights_dir": "unknown",
|
| 944 |
+
# "timestamp": datetime.utcnow().isoformat()
|
| 945 |
+
# }
|
| 946 |
|
| 947 |
+
# errors = {}
|
| 948 |
|
| 949 |
+
# # -------- 1. TORCH & CUDA CHECK --------
|
| 950 |
+
# try:
|
| 951 |
+
# checks["torch"] = torch.__version__
|
| 952 |
+
# checks["gpu"] = "available" if torch.cuda.is_available() else "cpu-only"
|
| 953 |
+
# if torch.cuda.is_available():
|
| 954 |
+
# checks["gpu_name"] = torch.cuda.get_device_name(0)
|
| 955 |
+
# checks["gpu_mem_allocated_mb"] = int(torch.cuda.memory_allocated(0) / 1024 / 1024)
|
| 956 |
+
# except Exception as e:
|
| 957 |
+
# checks["gpu"] = "failed"
|
| 958 |
+
# errors["gpu"] = str(e)
|
| 959 |
+
# # -------- 2. MONGODB CHECK (OPTIONAL) --------
|
| 960 |
+
# if _mongo_client is not None:
|
| 961 |
+
# try:
|
| 962 |
+
# def mongo_ping():
|
| 963 |
+
# _mongo_client.admin.command("ping")
|
| 964 |
|
| 965 |
+
# await run_in_threadpool(mongo_ping)
|
| 966 |
+
# checks["mongo"] = "connected"
|
| 967 |
+
# except Exception as e:
|
| 968 |
+
# checks["mongo"] = "failed"
|
| 969 |
+
# errors["mongo"] = str(e)
|
| 970 |
+
# else:
|
| 971 |
+
# checks["mongo"] = "not_configured"
|
| 972 |
|
| 973 |
+
# # -------- FINAL STATUS --------
|
| 974 |
+
# is_healthy = len(errors) == 0
|
| 975 |
|
| 976 |
+
# if is_healthy:
|
| 977 |
+
# checks["status"] = "healthy"
|
| 978 |
+
# return checks
|
| 979 |
|
| 980 |
+
# raise HTTPException(
|
| 981 |
+
# status_code=503,
|
| 982 |
+
# detail={
|
| 983 |
+
# "status": "unhealthy",
|
| 984 |
+
# "checks": checks,
|
| 985 |
+
# "errors": errors
|
| 986 |
+
# }
|
| 987 |
+
# )
|
| 988 |
@fastapi_app.get("/source")
|
| 989 |
def source(_: bool = Depends(_verify_bearer_token)):
|
| 990 |
return {
|