Skip to content

Instantly share code, notes, and snippets.

@jacobtomlinson
Created January 6, 2022 14:36
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobtomlinson/9a13c73e1845d64ffa34f4331824d7dd to your computer and use it in GitHub Desktop.
Save jacobtomlinson/9a13c73e1845d64ffa34f4331824d7dd to your computer and use it in GitHub Desktop.
Poke Dask dashboard
# A script that gives a local Dask cluster something to do without stressing hardware.
# Useful for testing the dashboard.
import time
from dask_ctl import get_cluster
from dask.distributed import Client, wait
from dask import delayed
cluster = get_cluster("proxycluster-8786")
client = Client(cluster)
@delayed
def inc(x):
time.sleep(0.1)
return x + 1
@delayed
def double(x):
time.sleep(0.1)
return 2 * x
@delayed
def add(x, y):
time.sleep(0.1)
return x + y
while True:
data = list(range(1000))
output = []
for x in data:
a = inc(x)
b = double(x)
c = add(a, b)
output.append(c)
total = delayed(sum)(output)
total = total.persist()
wait(total)
time.sleep(5)
del total
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment