⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Feat: rate limiting#437

Open
S1ro1 wants to merge 3 commits intomainfrom
feat-v2-rate-limit
Open

Feat: rate limiting#437
S1ro1 wants to merge 3 commits intomainfrom
feat-v2-rate-limit

Conversation

@S1ro1
Copy link
Member

@S1ro1 S1ro1 commented Feb 7, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 7, 2026 20:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable submission rate limiting to the leaderboard system (stored per leaderboard GPU type in Postgres), exposes management/query surfaces via Discord commands and API endpoints, and standardizes several timestamps to UTC.

Changes:

  • Add rate_limit_seconds to leaderboard.gpu_type and implement DB helpers to set/get/enforce limits.
  • Enforce rate limits during submission preparation and remove the prior hard-coded API-only rate limit.
  • Add admin/user-facing commands/endpoints for rate limit configuration + various UTC timestamp updates / formatting changes.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/migrations/20260207_01_EW7ve-leaderboard-rate-limits.py DB migration adding rate_limit_seconds to leaderboard.gpu_type.
src/libkernelbot/utils.py Makes parsed deadlines timezone-aware (UTC).
src/libkernelbot/submission.py Calls DB to enforce submission rate limits before accepting a submission.
src/libkernelbot/run_eval.py Records eval start/end timestamps in UTC.
src/libkernelbot/leaderboard_db.py Implements rate limit storage and checks in the DB layer.
src/libkernelbot/backend.py Uses UTC timestamps when creating submissions.
src/kernelbot/cogs/verify_run_cog.py Updates verify-task leaderboard deadline to UTC (but still calls create_leaderboard incorrectly).
src/kernelbot/cogs/misc_cog.py Adds a Discord command to view a leaderboard’s rate limits.
src/kernelbot/cogs/admin_cog.py Adds an admin Discord command to set a leaderboard GPU rate limit.
src/kernelbot/api/main.py Adds API endpoints to get/set rate limits; adjusts some timestamps/formatting.
src/kernelbot/api/api_utils.py Removes prior hard-coded rate limit check in request validation.
AGENTS.md Adds agent config pointer.
.ruff.toml Increases Ruff line length to 120.
Comments suppressed due to low confidence (1)

src/kernelbot/api/api_utils.py:145

  • _run_submission converts all exceptions into HTTP 400 responses. With rate limiting moved into prepare_submission, this will also turn rate-limit errors into 400s. Consider catching KernelBotError explicitly and using its http_code (e.g., 429) when raising HTTPException, while keeping other exceptions as 400/500 as appropriate.
async def _run_submission(submission: SubmissionRequest, mode: SubmissionMode, backend: KernelBackend):
    try:
        req = prepare_submission(submission, backend)
    except Exception as e:
        raise HTTPException(status_code=400, detail=str(e)) from e

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/libkernelbot
  backend.py
  leaderboard_db.py 1134-1137
  submission.py
  utils.py 64-69
Project Total  

This report was generated by python-coverage-comment-action

@msaroufim
Copy link
Member

@claude review this code please

Copy link
Member

@msaroufim msaroufim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably also want user based rate limits but LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants