Gee Xun Chen
05/20/2021, 3:48 AMcase .Gee Xun Chen
05/20/2021, 3:51 AMcondition task should be executed first. However, the case task executed first although it depends on the condition task
from prefect import Flow, Parameter, case, task
@task
def condition(table_path):
return table_path
@task
def run_if_cond_is_false():
print("a")
with Flow("example") as flow:
table_path = Parameter("table_path", default="customer_services/freshdesk/ticket/")
cond = condition(table_path)
with case(not cond, False):
run_if_cond_is_false()Gee Xun Chen
05/20/2021, 3:54 AMnot logic into the condition task, it works as expected (condition --> case --> run_if_cond_is_false)Gee Xun Chen
05/20/2021, 3:55 AMChris White
not Task evaluates immediately to False (instead of creating a dependency as you expect), hence the odd execution order you are observing.
To better see this for yourself, you can call flow.visualize() in both instances to see the dependency structure that Prefect detected — in your first case you will see two independent graphs with no dependency between them and in the second you will see the structure you are expecting.
The native Python operations that Prefect does and does not support could be better documented, so apologies for the confusion!Chris White
Marvin
05/20/2021, 4:05 AMGee Xun Chen
05/20/2021, 4:13 AM