Last active
September 10, 2021 08:23
-
-
Save lauralorenz/dab6810587b06ab43c944106b9f4c2d5 to your computer and use it in GitHub Desktop.
A diamond-shaped Prefect flow using mapping
This file contains 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
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