https://prefect.io logo
Title
m

Michael Hadorn

06/22/2022, 12:27 PM
I have a question about: restarted flows with trigger:any_successful tasks.
I have a flow with some tasks. At the end there I have a cleanup task (trigger: any_successful). So the cleanup task is always executed. Now if I got an error, I would like to restart the flow and also execute this cleanup task. But this cleanup-task is not executed, because it was already successful at the first run. But I need to rerun this. Is there an easy way to achieve this? Thanks in advance!!
k

Kevin Kho

06/22/2022, 1:15 PM
Did you try marking it as failed through the UI? I think that should make it run when you restart
m

Michael Hadorn

06/22/2022, 1:41 PM
@Kevin Kho Thanks for this advice. Yes this should work. But, it would be awesome if there would be an option for such tasks. Then it would be much easier to maintain bigger flows. Like: trigger=always ("all_finished" is described as "This is equivalent to "always run"" - https://docs.prefect.io/core/concepts/tasks.html#triggers but not in this case). So there is no automatic way to get this?
k

Kevin Kho

06/22/2022, 1:45 PM
I know what you mean. Definitely would not be added to 1.0, but worth opening a ticket for the idea. We’re still figuring out restarts in 2.0. @Marvin open “Feature request: label a cleanup task to always run during flow restarts” Do you need it as a task or can you use a state handler?
m
m

Michael Hadorn

06/22/2022, 2:00 PM
In my case I need a task. Is not only a cleanup, is also writing stats about the run and create some more data. Thank you!
k

Kevin Kho

06/22/2022, 2:01 PM
Ah ok I see