Skip to content
Closed
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 .github/workflows/amd_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
if [[ "${{ github.event.inputs.runner }}" == "amdgpu-mi250-x86-64" ]]; then
source ${VENV_DIR}/bin/activate
fi
python3 .github/workflows/runner.py
PYTHONPATH=src python3 src/runners/github-runner.py

- name: Upload training artifacts
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nvidia_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Run script
shell: bash
run: |
python .github/workflows/runner.py
PYTHONPATH=src python src/runners/github-runner.py
cat result.json # Debug: show output

- name: Upload training artifacts
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/runner_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:

- name: Run script
shell: bash
env:
PYTHONPATH: src
run: pytest scripts/ci_test_cuda.py

env:
Expand Down Expand Up @@ -62,6 +64,8 @@ jobs:

- name: Run script
shell: bash
env:
PYTHONPATH: src
run: pytest scripts/ci_test_python.py

env:
Expand Down
2 changes: 1 addition & 1 deletion examples/identity_py/submission.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!POPCORN leaderboard identity_py
#!POPCORN leaderboard identity_py-dev

from task import input_t, output_t

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ yoyo-migrations
ruff
pre-commit
better_profanity
pytest
PyYAML

# api
fastapi[all] # install all to avoid random bugs
Expand Down
11 changes: 2 additions & 9 deletions scripts/ci_test_cuda.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import os
import sys
import tempfile
from pathlib import Path

import pytest

if Path().resolve().name == "scripts":
os.chdir("..")

sys.path.append("src/discord-cluster-manager")

from consts import ExitCode, SubmissionMode
from run_eval import compile_cuda_script, run_cuda_script
from libkernelbot.consts import ExitCode, SubmissionMode
from libkernelbot.run_eval import compile_cuda_script, run_cuda_script

ref = Path("examples/identity_cuda/reference.cuh").read_text()
task_h = Path("examples/identity_cuda/task.h").read_text()
Expand Down
11 changes: 2 additions & 9 deletions scripts/ci_test_python.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import os
import sys
from pathlib import Path

if Path().resolve().name == "scripts":
os.chdir("..")

sys.path.append("src/discord-cluster-manager")

from consts import ExitCode, SubmissionMode
from run_eval import run_pytorch_script
from libkernelbot.consts import ExitCode, SubmissionMode
from libkernelbot.run_eval import run_pytorch_script

ref = Path("examples/identity_py/reference.py").read_text()
task = Path("examples/identity_py/task.py").read_text()
Expand Down
25 changes: 0 additions & 25 deletions scripts/local-test.py

This file was deleted.

47 changes: 0 additions & 47 deletions scripts/modal-test.py

This file was deleted.

50 changes: 0 additions & 50 deletions src/discord-cluster-manager/env.py

This file was deleted.

Empty file added src/kernelbot/api/__init__.py
Empty file.
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import requests
from backend import KernelBackend
from consts import SubmissionMode
from env import (
CLI_DISCORD_CLIENT_ID,
CLI_DISCORD_CLIENT_SECRET,
CLI_GITHUB_CLIENT_ID,
CLI_GITHUB_CLIENT_SECRET,
CLI_TOKEN_URL,
)
from fastapi import HTTPException
from report import Log, MultiProgressReporter, RunProgressReporter, RunResultReport, Text
from submission import SubmissionRequest, prepare_submission

from kernelbot.env import env
from libkernelbot.backend import KernelBackend
from libkernelbot.consts import SubmissionMode
from libkernelbot.report import (
Log,
MultiProgressReporter,
RunProgressReporter,
RunResultReport,
Text,
)
from libkernelbot.submission import SubmissionRequest, prepare_submission


async def _handle_discord_oauth(code: str, redirect_uri: str) -> tuple[str, str]:
"""Handles the Discord OAuth code exchange and user info retrieval."""
client_id = CLI_DISCORD_CLIENT_ID
client_secret = CLI_DISCORD_CLIENT_SECRET
token_url = CLI_TOKEN_URL
client_id = env.CLI_DISCORD_CLIENT_ID
client_secret = env.CLI_DISCORD_CLIENT_SECRET
token_url = env.CLI_TOKEN_URL
user_api_url = "https://discord.com/api/users/@me"

if not client_id:
Expand Down Expand Up @@ -76,8 +77,8 @@ async def _handle_discord_oauth(code: str, redirect_uri: str) -> tuple[str, str]

async def _handle_github_oauth(code: str, redirect_uri: str) -> tuple[str, str]:
"""Handles the GitHub OAuth code exchange and user info retrieval."""
client_id = CLI_GITHUB_CLIENT_ID
client_secret = CLI_GITHUB_CLIENT_SECRET
client_id = env.CLI_GITHUB_CLIENT_ID
client_secret = env.CLI_GITHUB_CLIENT_SECRET

token_url = "https://github.com/login/oauth/access_token"
user_api_url = "https://api.github.com/user"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
from dataclasses import asdict
from typing import Annotated, Optional

from backend import KernelBackend
from consts import SubmissionMode
from fastapi import Depends, FastAPI, Header, HTTPException, Request, UploadFile
from fastapi.responses import JSONResponse, StreamingResponse
from leaderboard_db import LeaderboardRankedEntry
from submission import SubmissionRequest
from utils import KernelBotError

from libkernelbot.backend import KernelBackend
from libkernelbot.consts import SubmissionMode
from libkernelbot.leaderboard_db import LeaderboardRankedEntry
from libkernelbot.submission import SubmissionRequest
from libkernelbot.utils import KernelBotError

from .api_utils import _handle_discord_oauth, _handle_github_oauth, _run_submission

Expand Down Expand Up @@ -309,7 +310,7 @@ async def run_submission( # noqa: C901
user_id (str): The validated user ID obtained from the X-Popcorn-Cli-Id header.

Raises:
HTTPException: If the bot is not initialized, or header/input is invalid.
HTTPException: If the kernelbot is not initialized, or header/input is invalid.

Returns:
StreamingResponse: A streaming response containing the status and results of the submission.
Expand Down
Empty file added src/kernelbot/cogs/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@
from typing import TYPE_CHECKING, Optional, TypedDict

import discord
import env
import yaml
from consts import GitHubGPU, ModalGPU
from discord import app_commands
from discord.ext import commands, tasks
from discord_utils import leaderboard_name_autocomplete, send_discord_message, with_error_handling
from leaderboard_db import LeaderboardDoesNotExist, LeaderboardItem, SubmissionItem
from task import LeaderboardDefinition, make_task_definition
from ui.misc import ConfirmationView, DeleteConfirmationModal, GPUSelectionView
from utils import (

from kernelbot.discord_utils import (
leaderboard_name_autocomplete,
send_discord_message,
with_error_handling,
)
from kernelbot.env import env
from kernelbot.ui.misc import ConfirmationView, DeleteConfirmationModal, GPUSelectionView
from libkernelbot.consts import GitHubGPU, ModalGPU
from libkernelbot.leaderboard_db import LeaderboardDoesNotExist, LeaderboardItem, SubmissionItem
from libkernelbot.task import LeaderboardDefinition, make_task_definition
from libkernelbot.utils import (
KernelBotError,
setup_logging,
)

if TYPE_CHECKING:
from ..bot import ClusterBot
from kernelbot.main import ClusterBot

logger = setup_logging()

Expand Down Expand Up @@ -66,7 +71,7 @@ class AdminCog(commands.Cog):
def __init__(self, bot: "ClusterBot"):
self.bot = bot

# create-local should only be used for the development bot
# create-local should only be used for the development kernelbot
if self.bot.debug_mode:
self.leaderboard_create_local = bot.admin_group.command(
name="create-local",
Expand All @@ -82,19 +87,19 @@ def __init__(self, bot: "ClusterBot"):
)(self.delete_submission)

self.accept_jobs = bot.admin_group.command(
name="start", description="Make the bot accept new submissions"
name="start", description="Make the kernelbot accept new submissions"
)(self.start)

self.reject_jobs = bot.admin_group.command(
name="stop", description="Make the bot stop accepting new submissions"
name="stop", description="Make the kernelbot stop accepting new submissions"
)(self.stop)

self.update_problems = bot.admin_group.command(
name="update-problems", description="Reload all problem definitions"
)(self.update_problems)

self.show_bot_stats = bot.admin_group.command(
name="show-stats", description="Show stats for the bot"
name="show-stats", description="Show stats for the kernelbot"
)(self.show_bot_stats)

self.resync = bot.admin_group.command(
Expand Down
Loading
Loading