Skip to content

Commit

Permalink
test_jobqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
gjoseph92 committed Aug 12, 2022
1 parent 031df08 commit 270fac6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/workloads/test_custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from dask import delayed
from dask.utils import parse_bytes
import time
import random

from ..utils_test import wait


def test_jobqueue(small_client):
# Just using dask to run lots of embarrassingly-parallel CPU-bound tasks as fast as possible
nthreads = sum(
w["nthreads"] for w in small_client.scheduler_info()["workers"].values()
)
max_runtime = 120
max_sleep = 3
n_tasks = max_runtime / max_sleep * nthreads

@delayed(pure=True)
def task(i: int) -> int:
stuff = "x" * parse_bytes("400MiB")
time.sleep(random.uniform(0, max_sleep))
return i

tasks = [task(i) for i in range(n_tasks)]
result = delayed(sum)(*tasks) # just so we have a single object

wait(
result,
small_client,
max_runtime * 1.15,
)

0 comments on commit 270fac6

Please sign in to comment.