https://prefect.io logo
s

Sanz Al

08/22/2023, 2:40 PM
Question about retries: if I implement the retry at flow level, is there a way to execute only the failed tasks on the next retry?
j

Jeff Hale

08/23/2023, 11:51 AM
I looked into this a bit and a believe the answer is no, but will inquire further.
👍 1
Ah, I was wrong. I tested a bit and tasks that finish in a completed state don’t retry. It will show that they finish in state completed as many times as the flow retries, but it’s not actually rerunning. Here’s a basic script. You’ll note in the task logs in the UI that it only prints “trying task 1” one time.
Copy code
from prefect import task, flow

@task()
def task1():
    print("trying task 1")

@task()
def task2():
    print("trying task 2")
    raise ValueError("fail")


@flow(retries=2, log_prints=True)
def run_tasks():
    task1()
    task2()

if __name__ == "__main__":
    run_tasks()
s

Sanz Al

08/24/2023, 7:03 AM
Oh, that’s the behaviour I was looking for! Thanks for checking further.
👍 1