Atul Anand
03/31/2022, 2:48 PMKevin Kho
Atul Anand
03/31/2022, 2:53 PM@task
def inc(x):
sleep(random.random() / 10)
return x + 1
@task
def dec(x):
sleep(random.random() / 10)
return x - 1
@task
def add(x, y):
sleep(random.random() / 10)
return x + y
@task(name="sum")
def list_sum(arr):
return sum(arr)
with Flow("dask-example") as flow:
incs = inc.map(x=range(100))
decs = dec.map(x=range(100))
adds = add.map(x=incs, y=decs)
total = list_sum(adds)
if __name__ == "__main__":
executor = DaskExecutor(
debug=True,
address="192.168.25.171:8786"
)
flow.executor = executor
flow.run()
Have a look on this
Kevin Kho
prefecthq/prefect
Atul Anand
03/31/2022, 3:01 PMKevin Kho
Atul Anand
03/31/2022, 3:07 PMKevin Kho
Atul Anand
03/31/2022, 4:19 PMKevin Kho