How can I build conditional logic within a flow?

Prefect 2.0

Orion allows you to run any Python code in your flow. Therefore, you can use the native Python if/else statements to specify conditional logic. Here is an example:

from prefect import task, flow

def get_color():
    return "green"

def main_flow():
    color = get_color().wait().result()
    if color == "green":
        print("Green light!")

if __name__ == "__main__":

Prefect 1.0

Prefect 1.0 provides special tasks allowing to build conditional logic. You can import those tasks (case, merge, ifelse, switch) from prefect.tasks.control_flow.