Created
January 6, 2022 14:36
-
-
Save jacobtomlinson/9a13c73e1845d64ffa34f4331824d7dd to your computer and use it in GitHub Desktop.
Poke Dask dashboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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