Created
May 15, 2020 12:54
-
-
Save jlowin/813a738e18337e3adee42380367e14fe to your computer and use it in GitHub Desktop.
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, Parameter | |
from prefect.tasks.control_flow import case | |
@task | |
def send_email(email): | |
print(f"Sending an email to {email}") | |
@task | |
def send_postcard(planet): | |
print(f"Sending a postcard to {planet}") | |
with Flow("Conditional Example") as flow: | |
username = Parameter("username") | |
with case(username, "arthur"): | |
send_postcard("earth") | |
with case(username, "marvin"): | |
send_email("[email protected]") | |
flow.run(username="marvin") # sending an email to [email protected] | |
flow.run(username="arthur") # sending a postcard to earth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment