Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/discord-cluster-manager/api/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async def _run_submission(
submission: SubmissionRequest, mode: SubmissionMode, backend: KernelBackend
):
try:
req = prepare_submission(submission, backend.db)
req = prepare_submission(submission, backend)
except Exception as e:
raise HTTPException(status_code=400, detail=str(e)) from e

Expand Down
8 changes: 3 additions & 5 deletions src/discord-cluster-manager/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import json
import os
import time
from contextlib import contextmanager
from dataclasses import asdict
from typing import Annotated, Optional

Expand Down Expand Up @@ -66,14 +65,12 @@ async def kernel_bot_error_handler(req: Request, exc: KernelBotError):
return JSONResponse(status_code=exc.http_code, content={"message": str(exc)})


@contextmanager
def get_db():
"""Database context manager with guaranteed error handling"""
if not backend_instance:
raise HTTPException(status_code=500, detail="Bot instance not initialized")

with backend_instance.db as db:
yield db
return backend_instance.db


async def validate_cli_header(
Expand Down Expand Up @@ -359,7 +356,8 @@ async def run_submission( # noqa: C901
raise
except Exception as e:
raise HTTPException(
status_code=500, detail=f"Internal server error while validating leaderboard/GPU: {e}"
status_code=500,
detail=f"Internal server error while validating leaderboard/GPU: {e}",
) from e

try:
Expand Down
Loading