Skip to content

Instantly share code, notes, and snippets.

@jlowin
Created May 15, 2020 12:54
Show Gist options
  • Save jlowin/813a738e18337e3adee42380367e14fe to your computer and use it in GitHub Desktop.
Save jlowin/813a738e18337e3adee42380367e14fe to your computer and use it in GitHub Desktop.
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