Skip to content

Instantly share code, notes, and snippets.

@lauralorenz
Last active September 10, 2021 08:23
Show Gist options
  • Save lauralorenz/dab6810587b06ab43c944106b9f4c2d5 to your computer and use it in GitHub Desktop.
Save lauralorenz/dab6810587b06ab43c944106b9f4c2d5 to your computer and use it in GitHub Desktop.
A diamond-shaped Prefect flow using mapping
from prefect import task, Flow
import datetime
import random
@task
def inc(x):
return x + 1
@task
def dec(x):
return x - 1
@task
def add(x, y):
return x + y
@task
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment