Hello. What is the correct way to fail task that h...
# prefect-community
v
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
Exactly, you can raise an ENDRUN signal and this way Prefect won't attempt any additional retries
v
It will fail whole flow as well, right?
a
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
Will I see error message in Prefect UI?
Copy code
raise ENDRUN(
    state=Failed(f'Failed to parse {file} with {FILE_PATTERN}'),
)
a
test it out 🙂 you should see exactly the same message that you defined in your Failed state:
Copy code
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
Thanks!
👍 1