https://prefect.io logo
Title
v

Vadym Dytyniak

03/22/2022, 8:53 AM
Hello. What is the correct way to fail task that have retry logic, but I am sure that even 100 retries will not help?
Is it correct approach?
a

Anna Geller

03/22/2022, 9:15 AM
Exactly, you can raise an ENDRUN signal and this way Prefect won't attempt any additional retries
v

Vadym Dytyniak

03/22/2022, 9:19 AM
It will fail whole flow as well, right?
a

Anna Geller

03/22/2022, 9:56 AM
No, it will only end the task run in which you raise the signal. But if this task is a reference task, then yes the effect will be that this flow run will be considered failed
v

Vadym Dytyniak

03/22/2022, 10:26 AM
Will I see error message in Prefect UI?
raise ENDRUN(
    state=Failed(f'Failed to parse {file} with {FILE_PATTERN}'),
)
a

Anna Geller

03/22/2022, 11:01 AM
test it out 🙂 you should see exactly the same message that you defined in your Failed state:
from prefect.engine.signals import ENDRUN
from prefect.engine.state import Failed
from prefect import task


@task
def end_with_failure():
    raise ENDRUN(Failed(message="your_message"))
v

Vadym Dytyniak

03/22/2022, 11:04 AM
Thanks!
👍 1