Tri
10/24/2024, 5:18 PMNate
10/24/2024, 5:46 PMWhen a task in the middle of a flow fail, will i get notification?you can, you have to set up a notification. there are a couple ways to do that • create an automation • use an
on_failure
hook
And can i rerun that task to resume the flow from that task? Or can I skip the failed task and resume the flow after task?yes! consider this example
from prefect import flow, task
from prefect.cache_policies import INPUTS
count = 0
@task(cache_policy=INPUTS)
def double(x: int) -> int:
global count
if count == 1:
return x * 2
count += 1
raise ValueError("Intentional failure")
@task(cache_policy=INPUTS)
def always_succeeds(x: int) -> int:
return x + 1
@flow(retries=1, retry_delay_seconds=5)
def f():
always_succeeds(3)
return double(4)
f()
where we simulate a failure the first time, and then it succeeds on retry, and any upstream tasks that already completed would be cached