Skip to content

Commit

Permalink
adds gpu_type column to submission table (#79)
Browse files Browse the repository at this point in the history
* adds gpu_type column to submission table

* changes to make ruff happy
  • Loading branch information
b9r5 authored Dec 26, 2024
1 parent 8e02dbe commit 38b02b1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/discord-cluster-manager/cogs/leaderboard_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ async def submit_modal(
"code": submission_content,
"user_id": interaction.user.id,
"submission_score": score,
"gpu_type": gpu_type.name,
}
)

Expand Down Expand Up @@ -179,6 +180,8 @@ async def submit_github(
"code": submission_content,
"user_id": interaction.user.id,
"submission_score": score,
# TODO: Change this to multiple GPUs (see above)
"gpu_type": "nvidia",
}
)

Expand Down Expand Up @@ -420,6 +423,7 @@ async def get_leaderboard_submissions(
self,
interaction: discord.Interaction,
leaderboard_name: str,
# TODO add GPU type
):
try:
with self.bot.leaderboard_db as db:
Expand Down
9 changes: 7 additions & 2 deletions src/discord-cluster-manager/leaderboard_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ def create_submission(self, submission: SubmissionItem):
self.cursor.execute(
"""
INSERT INTO leaderboard.submission (leaderboard_id, name,
user_id, code, submission_time, score)
user_id, code, submission_time, score, gpu_type, stdout,
profiler_output)
VALUES (
(SELECT id FROM leaderboard.leaderboard WHERE name = %s),
%s, %s, %s, %s, %s)
%s, %s, %s, %s, %s, %s, %s, %s)
""",
(
submission["leaderboard_name"],
Expand All @@ -144,6 +145,9 @@ def create_submission(self, submission: SubmissionItem):
submission["code"],
submission["submission_time"],
submission["submission_score"],
submission["gpu_type"],
submission.get("stdout", None),
submission.get("profiler_output", None),
),
)
self.connection.commit()
Expand Down Expand Up @@ -193,6 +197,7 @@ def get_leaderboard(self, leaderboard_name: str) -> int | None:
else:
return None

# TODO: add GPU type
def get_leaderboard_submissions(self, leaderboard_name: str) -> list[SubmissionItem]:
self.cursor.execute(
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
This migration adds a score column to runinfo, and drops the score column in
submission.
"""

from yoyo import step

__depends__ = {'20241224_01_Pg4FX-delete-cascade'}

steps = [
step("DROP TABLE leaderboard.runinfo"),

step("""
ALTER TABLE leaderboard.submission
ADD COLUMN gpu_type TEXT NOT NULL DEFAULT 'nvidia'
"""),

step("ALTER TABLE leaderboard.submission ADD COLUMN stdout TEXT"),

step("ALTER TABLE leaderboard.submission ADD COLUMN profiler_output TEXT"),
]
11 changes: 4 additions & 7 deletions src/discord-cluster-manager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re
import subprocess
from typing import Any, List, TypedDict
from typing import Any, List, NotRequired, TypedDict

import discord

Expand Down Expand Up @@ -143,9 +143,6 @@ class SubmissionItem(TypedDict):
leaderboard_name: str
code: str
user_id: int


class ProfilingItem(TypedDict):
submission_name: str
ncu_output: str
stdout: str
gpu_type: str
stdout: NotRequired[str]
profiler_output: NotRequired[str]

0 comments on commit 38b02b1

Please sign in to comment.