Skip to content

Commit aa3e6ae

Browse files
committed
fix tests
1 parent 01ee978 commit aa3e6ae

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

src/libkernelbot/run_eval.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ def compile_cuda_script( # # noqa: C901
218218
)
219219

220220

221-
def run_program(args: list[str], seed: Optional[int], timeout: int, multi_gpu: bool = False) -> RunResult:
221+
def run_program(
222+
args: list[str], seed: Optional[int], timeout: int, multi_gpu: bool = False
223+
) -> RunResult:
222224
print("[Running]")
223225
# set up a pipe so the tester can communicate its verdict with us
224226
env = os.environ.copy()
@@ -229,6 +231,7 @@ def run_program(args: list[str], seed: Optional[int], timeout: int, multi_gpu: b
229231

230232
if multi_gpu:
231233
import torch
234+
232235
env["POPCORN_GPUS"] = str(torch.cuda.device_count())
233236

234237
execution_start_time = time.perf_counter()
@@ -302,7 +305,9 @@ def run_single_evaluation(
302305
with tempfile.NamedTemporaryFile("w") as tests_file:
303306
tests_file.write(tests)
304307
tests_file.flush()
305-
return run_program(call + [mode, tests_file.name], seed=seed, timeout=test_timeout, multi_gpu=multi_gpu)
308+
return run_program(
309+
call + [mode, tests_file.name], seed=seed, timeout=test_timeout, multi_gpu=multi_gpu
310+
)
306311
elif mode in ["benchmark", "profile", "leaderboard"]:
307312
timeout = ranked_timeout if mode == "leaderboard" else benchmark_timeout
308313
with tempfile.NamedTemporaryFile("w") as bench_file:
@@ -311,7 +316,9 @@ def run_single_evaluation(
311316
else:
312317
bench_file.write(benchmarks)
313318
bench_file.flush()
314-
return run_program(call + [mode, bench_file.name], seed=seed, timeout=timeout, multi_gpu=multi_gpu)
319+
return run_program(
320+
call + [mode, bench_file.name], seed=seed, timeout=timeout, multi_gpu=multi_gpu
321+
)
315322
else:
316323
raise ValueError(f"Invalid mode {mode}")
317324

src/libkernelbot/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class LeaderboardDefinition:
114114
templates: dict[str, str] = dataclasses.field(default_factory=dict)
115115

116116

117-
def make_task_definition(yaml_file: str | Path) -> LeaderboardDefinition:
117+
def make_task_definition(yaml_file: str | Path) -> LeaderboardDefinition: # noqa: C901
118118
if Path(yaml_file).is_dir():
119119
yaml_file = Path(yaml_file) / "task.yml"
120120

tests/test_backend.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ async def test_submit_leaderboard(bot: backend.KernelBackend, task_directory):
153153
"lang": "py",
154154
"main": "kernel.py",
155155
"mode": "leaderboard",
156+
"multi_gpu": False,
156157
"ranked_timeout": 180,
157158
"ranking_by": "geom",
158159
"seed": 1337,
@@ -206,6 +207,7 @@ async def test_submit_leaderboard(bot: backend.KernelBackend, task_directory):
206207
"start_time": eval_result.start.replace(tzinfo=datetime.timezone.utc),
207208
"system": {
208209
"cpu": "Intel i9-12900K",
210+
"device_count": 1,
209211
"gpu": "NVIDIA RTX 4090",
210212
"platform": "Linux-5.15.0",
211213
"torch": "2.0.1+cu118",
@@ -310,6 +312,7 @@ async def test_submit_full(bot: backend.KernelBackend, task_directory):
310312
"start_time": ANY,
311313
"system": {
312314
"cpu": "Intel i9-12900K",
315+
"device_count": 1,
313316
"gpu": "NVIDIA RTX 4090",
314317
"platform": "Linux-5.15.0",
315318
"torch": "2.0.1+cu118",
@@ -351,6 +354,7 @@ async def test_submit_full(bot: backend.KernelBackend, task_directory):
351354
"start_time": ANY,
352355
"system": {
353356
"cpu": "Intel i9-12900K",
357+
"device_count": 1,
354358
"gpu": "NVIDIA RTX 4090",
355359
"platform": "Linux-5.15.0",
356360
"torch": "2.0.1+cu118",

tests/test_modal.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,10 @@ async def test_modal_launcher_python_script(
187187
@pytest.mark.integration
188188
@pytest.mark.asyncio
189189
@pytest.mark.parametrize("script, good", [("submission.py", True), ("wrong.py", False)])
190-
async def test_modal_multi_gpu(
191-
modal_deployment, project_root: Path, script: str, good: bool
192-
):
190+
async def test_modal_multi_gpu(modal_deployment, project_root: Path, script: str, good: bool):
193191
"""
194-
This isn't really a modal test, but instead a test using modal to check that multi-gpu submission
195-
testing works (on modal...).
192+
This isn't really a modal test, but instead a test using modal to check
193+
that multi-gpu submission testing works (on modal...).
196194
"""
197195
launcher = ModalLauncher(add_include_dirs=[])
198196
reporter = MockProgressReporter("progress")
@@ -245,8 +243,8 @@ async def test_modal_multi_gpu_benchmark(
245243
modal_deployment, project_root: Path, script: str, good: bool
246244
):
247245
"""
248-
This isn't really a modal test, but instead a test using modal to check that multi-gpu submission
249-
testing works (on modal...).
246+
This isn't really a modal test, but instead a test using modal
247+
to check that multi-gpu submission testing works (on modal...).
250248
"""
251249
launcher = ModalLauncher(add_include_dirs=[])
252250
reporter = MockProgressReporter("progress")

0 commit comments

Comments
 (0)