Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Upload 6 files
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ from huggingface_hub import HfApi, attach_huggingface_oauth
|
|
| 12 |
|
| 13 |
from src.bucket import RunPaths, check_user_bucket, create_user_bucket, delete_run_folder, read_run_bundle, list_recent_runs, write_json, write_launch_metadata
|
| 14 |
from src.config import settings, user_bucket_source
|
| 15 |
-
from src.eval_config import activate_eval_archive_config, public_eval_config
|
| 16 |
from src.eval_archive import maybe_publish_eval_record
|
| 17 |
from src.auth import extract_oauth_context, public_oauth_context, oauth_warning_messages, verify_token_identity
|
| 18 |
from src.jobs import (
|
|
@@ -307,6 +307,17 @@ def register_custom_routes(fastapi_app: FastAPI) -> None:
|
|
| 307 |
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
| 308 |
return JSONResponse(cfg)
|
| 309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
@fastapi_app.get("/api/oauth/diagnostics")
|
| 311 |
async def api_oauth_diagnostics(request: Request): # type: ignore[no-untyped-def]
|
| 312 |
ctx = extract_oauth_context(request)
|
|
|
|
| 12 |
|
| 13 |
from src.bucket import RunPaths, check_user_bucket, create_user_bucket, delete_run_folder, read_run_bundle, list_recent_runs, write_json, write_launch_metadata
|
| 14 |
from src.config import settings, user_bucket_source
|
| 15 |
+
from src.eval_config import activate_eval_archive_config, disable_eval_archive_config, public_eval_config
|
| 16 |
from src.eval_archive import maybe_publish_eval_record
|
| 17 |
from src.auth import extract_oauth_context, public_oauth_context, oauth_warning_messages, verify_token_identity
|
| 18 |
from src.jobs import (
|
|
|
|
| 307 |
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
| 308 |
return JSONResponse(cfg)
|
| 309 |
|
| 310 |
+
@fastapi_app.post("/api/eval-archive/disable")
|
| 311 |
+
async def api_eval_archive_disable(request: Request): # type: ignore[no-untyped-def]
|
| 312 |
+
ctx = _oauth_context_from_request(request)
|
| 313 |
+
try:
|
| 314 |
+
cfg = disable_eval_archive_config(username=ctx["username"])
|
| 315 |
+
except PermissionError as exc:
|
| 316 |
+
raise HTTPException(status_code=403, detail=str(exc)) from exc
|
| 317 |
+
except Exception as exc: # noqa: BLE001
|
| 318 |
+
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
| 319 |
+
return JSONResponse(cfg)
|
| 320 |
+
|
| 321 |
@fastapi_app.get("/api/oauth/diagnostics")
|
| 322 |
async def api_oauth_diagnostics(request: Request): # type: ignore[no-untyped-def]
|
| 323 |
ctx = extract_oauth_context(request)
|