Max Eggers
05/16/2024, 2:30 AMMarvin
05/16/2024, 2:31 AMretries
and retry_delay_seconds
parameters on a task to specify how many times it should retry and the delay between retries. Here's a conceptual example:
python
import httpx
from prefect import flow, task
@task(retries=2, retry_delay_seconds=10)
def potentially_crashing_task():
# Your task logic here
...
@flow
def my_flow():
potentially_crashing_task()
my_flow()
In this case, if potentially_crashing_task
crashes, Prefect will automatically retry the task up to 2 times, with a delay of 10 seconds between retries. Note that retries do not create new task runs but add a new state to the state history of the original task run.
If you are working with dbt Cloud specifically, there is a function in the prefect-dbt
library called run_dbt_cloud_job
that includes a targeted_retries
parameter for retrying failed steps. The documentation can be found here.
For more detailed information on handling retries and tasks in Prefect, you can check the Tasks concept documentation.Max Eggers
05/16/2024, 2:32 AMMarvin
05/16/2024, 2:32 AM