https://prefect.io logo
Title
z

Zach Schumacher

02/24/2022, 4:27 PM
hi all, I'm trying to do a conditional flow, but as you can see i get matches, check if the matches are valid, and then only want to continue if they are. Because i am passing matches into those tasks, they run regardless of if the condition is true or not. What am i doing wrong here?
with flow:
    start_date, end_date = Parameter("start-date", default=None), Parameter("end-date", default=None)
    start_date, end_date = set_date_params(start_date, end_date)
    matches = get_completed_matches_by_date_range(start_date, end_date)
    there_are_matches = are_there_any_matches(matches)
    with case(there_are_matches, True):
        some_data = some_task.run(matches)
k

Kevin Kho

02/24/2022, 4:32 PM
Why are you calling the
.run
under case?
some_task
should have two upstream with the case and matches and the case should evaluate as False causing it to not run I think
z

Zach Schumacher

02/24/2022, 4:33 PM
thats probably misleading, the module is "some_task" and the function is run
e.g. if im calling it not in flow context i'd do some_task.run.run
k

Kevin Kho

02/24/2022, 4:34 PM
Ah I see what you mean. I think you can visualize the DAG to see the upstreams?
z

Zach Schumacher

02/24/2022, 4:35 PM
yeah thats what was misleading, but maybe the behavior isn't actually what the dag is showing
i think i understand now
yeah it is working like intended, i just misinterpreted the graph
k

Kevin Kho

02/24/2022, 4:36 PM
ah ok