-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinc_dask.py
More file actions
40 lines (28 loc) · 796 Bytes
/
inc_dask.py
File metadata and controls
40 lines (28 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from dask import delayed
from dask_jobqueue import SLURMCluster
from distributed import Client, wait
from time import sleep, time
from dask_cluster import create_dask_client
#Aqui intentamos conectarnos al cliente
info = "./scheduler_info.json"
client = create_dask_client(info)
def inc(x):
#Espera 1 segundo y suma uno a la entrada
sleep(1)
return x + 1
#inc_delayed = delayed(inc)
data = [1, 2, 3, 4]
result = []
#Enviamos el calculo al cluster
for x in data:
y = client.submit(inc, x)
result.append(y)
inicio = time()
#recogemos el calculo del cluster
final = client.gather(result)
#final = result.result()
fin = time()
print("Resultados= {}".format(final))
print("Tiempo= {}".format(fin-inicio))
#Cerramos el cliente para que todo acabe bien
client.shutdown()