Skip to content
Open
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
59 changes: 59 additions & 0 deletions .github/workflows/deploy-challenges.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy Challenges

on:
push:
branches:
- main
paths:
- 'challenges/**'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Install dependencies
run: |
pip install requests

- name: Get changed challenges
id: changed
run: |
git diff --name-only HEAD~1 HEAD | grep '^challenges/' > changed_files.txt || true

if [ -s changed_files.txt ]; then
# Extract unique challenge directories (e.g., challenges/easy/1_vector_add -> challenges/easy/1_vector_add)
cat changed_files.txt | sed 's|\(challenges/[^/]*/[^/]*\)/.*|\1|' | sort -u > challenge_paths.txt

if [ -s challenge_paths.txt ]; then
echo "paths<<EOF" >> $GITHUB_OUTPUT
cat challenge_paths.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
fi

- name: Deploy changed challenges
if: steps.changed.outputs.paths != ''
env:
SERVICE_URL: ${{ secrets.LEETGPU_SERVICE_URL }}
LEETGPU_API_KEY: ${{ secrets.LEETGPU_API_KEY }}
run: |
if [ -z "$LEETGPU_API_KEY" ]; then
echo "Error: LEETGPU_API_KEY secret is not set"
exit 1
fi

echo "${{ steps.changed.outputs.paths }}" | while read -r path; do
if [ -d "$path" ]; then
echo "Deploying $path"
python scripts/update_challenges.py "$path"
fi
done
58 changes: 58 additions & 0 deletions challenges/core/challenge_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from abc import ABC, abstractmethod
from typing import Any, List, Dict

class ChallengeBase(ABC):
def __init__(self, name: str, atol: float, rtol: float, num_gpus: int, access_tier: str):
self.name = name
self.atol = atol
self.rtol = rtol
self.num_gpus = num_gpus
self.access_tier = access_tier

@abstractmethod
def reference_impl(self, *args, **kwargs):
"""
Reference solution implementation.
"""
pass

@abstractmethod
def get_solve_signature(self) -> Dict[str, Any]:
"""
Get the function signature for solution.

Returns:
Dictionary with argtypes and restype for ctypes
"""
pass

@abstractmethod
def generate_example_test(self) -> List[Dict[str, Any]]:
"""
Generate an example test case for this problem.

Returns:
Dictionary with test case parameters
"""
pass

@abstractmethod
def generate_functional_test(self) -> List[Dict[str, Any]]:
"""
Generate functional test cases for this problem.

Returns:
List of test case dictionaries
"""
pass

@abstractmethod
def generate_performance_test(self) -> List[Dict[str, Any]]:
"""
Generate a performance test case for this problem.

Returns:
Dictionary with test case parameters
"""
pass

1 change: 0 additions & 1 deletion challenges/medium/36_radix_sort/challenge.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ctypes
from typing import Any, List, Dict
import torch
import numpy as np
from core.challenge_base import ChallengeBase

class Challenge(ChallengeBase):
Expand Down
257 changes: 0 additions & 257 deletions scripts/generate_starter_code.py

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests
websocket-client
Loading