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
3 changes: 2 additions & 1 deletion .github/workflows/amd_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ jobs:
EOL
pip install -r "requirements.txt"
fi
pip install -e .

- name: Run script
shell: bash
run: |
if [[ "${{ github.event.inputs.runner }}" == "amdgpu-mi250-x86-64" ]]; then
source ${VENV_DIR}/bin/activate
fi
python3 .github/workflows/runner.py
python3 src/runners/github-runner.py

- name: Upload training artifacts
uses: actions/upload-artifact@v4
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/nvidia_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
with:
python-version: '3.10'

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Create input files
shell: bash
run: |
Expand Down Expand Up @@ -62,11 +67,12 @@ jobs:
EOL
uv pip install -r "requirements.txt"
fi
uv pip install -e .

- name: Run script
shell: bash
run: |
python .github/workflows/runner.py
python src/runners/github-runner.py
cat result.json # Debug: show output

- name: Upload training artifacts
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/runner_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,21 @@ jobs:
with:
python-version: '3.10'

- name: Install pytest
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Setup Python environment
run: |
uv venv .venv
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
uv pip install pytest

- name: Install package
shell: bash
run: pip install pytest
run: uv pip install -e .

- name: Run script
shell: bash
Expand Down Expand Up @@ -60,6 +72,10 @@ jobs:
echo "$PWD/.venv/bin" >> $GITHUB_PATH
uv pip install numpy torch setuptools ninja pytest

- name: Install package
shell: bash
run: uv pip install -e .

- name: Run script
shell: bash
run: pytest scripts/ci_test_python.py
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
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "discord-cluster-manager"
version = "0.1.0"
description = "Discord bot for managing compute clusters and running kernel benchmarks"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"PyGithub",
"aiohttp",
"discord.py",
"audioop-lts; python_version >= '3.13'",
"python-dotenv",
"requests",
"modal",
"psycopg2-binary",
"yoyo-migrations",
"better_profanity",
"PyYAML",
"fastapi[all]",
"uvicorn",
"jinja2",
]

[project.optional-dependencies]
dev = [
"ruff",
"pre-commit",
"pytest",
]

[tool.setuptools.packages.find]
where = ["src"]

[tool.pytest.ini_options]
testpaths = ["scripts", "tests"]
python_files = ["test_*.py", "*_test.py", "ci_test_*.py"]

[tool.ruff]
line-length = 120
target-version = "py310"
20 changes: 0 additions & 20 deletions requirements.txt

This file was deleted.

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.
Loading
Loading