Hi All, I manage several flows and tasks, each of ...
# ask-community
m
Hi All, I manage several flows and tasks, each of which has its own set of parameters. I'm looking to configure Prefect so that when a task is running with parameters (X=y and Z=w), only that specific task will execute, while any other tasks with the same parameters will wait. Thanks
j
Does checking the values and conditionally calling the tasks work? Something like this:
Copy code
from prefect import flow, task


@task
def task1(input1, input2):
    print("task 1 executed")


@task
def task2(input1, input2):
    print("task 2 executed")


@flow()
def controller(x, z):
    if x == "y" and z == "w":
        result = task1(x, z)
    if x == "a" and z == "b":
        result = task2(x, z)
    return result


if __name__ == "__main__":
    controller(x="y", z="w")
    # controller(x="a", z="b")
Or with match/case if using Python 3.10 and you have a bunch of potential branches?