https://prefect.io logo
Title
b

Bradley Hurley

04/26/2022, 5:21 PM
Hi Prefect Experts - Is it possible if I have a flow run thats in a failed/cancelled state, to clear the state of a task thats already succeeded so that when the flow is restarted the previously successful task will re-execute? I know you can do that sort of thing with Airflow, but wasn't able to replicate with Prefect.
Task1 (Success) -> Task2 (Success) -> Task3 (Failed)-> Task4 (Queued)
I want to clear Task2 and have Task2, Task3, and Task4 run when restarting the flow
k

Kevin Kho

04/26/2022, 5:24 PM
At this point though, doesn’t a new flow run give you what you are intending?
b

Bradley Hurley

04/26/2022, 5:26 PM
Not if Task1 takes 6 hours to run.
I think I need to look at output caching and new flow runs vs restarts.
k

Kevin Kho

04/26/2022, 5:27 PM
We can explicitly cache Task 1 so that it doesn’t re-run across flow runs. That would be the easier approach then moving those successful tasks back to Scheduled
You can just use the
cache_for
and give a duration like shown here
b

Bradley Hurley

04/26/2022, 5:28 PM
Thanks! I will give this a shot.
s

Scott McCallen

04/26/2022, 5:33 PM
Would changing the state of Task2 to Scheduled achieve the desired result? E.g. Task2, Task3, and Task4 are executed
k

Kevin Kho

04/26/2022, 5:34 PM
Not quite, I think Task 2 will re-run but Task 3 won’t because it’s already in a SUCCESS state. You need all of them to be moved to a Scheduled state
b

Bradley Hurley

04/26/2022, 5:35 PM
Is it possible to change the state of a task? I thought you could only change the state of the overall flow run.
k

Kevin Kho

04/26/2022, 5:36 PM
You can, you can even do it through the UI. Just navigate to a task run page and set the state
b

Bradley Hurley

04/26/2022, 5:40 PM
Thanks! Im not sure how I overlooked that.