`allow_failure` does not work as expected I am tr...
# prefect-community
y
allow_failure
does not work as expected I am trying to see how can I continue with a workflow after a task failed all the allowed retries. Sample code:
Copy code
from prefect import task, flow, get_run_logger, allow_failure
from time import sleep


@task(retries=2, timeout_seconds=3)
def test_1(o, test_retries):
    if test_retries:
        sleep(5)
    else:
        raise IOError('Raising some error')
    return True


@flow(name='test allow_failure')
def run_test_flow():
    result = test_1.submit(True, True)
    result = test_1.submit(result, False, wait_for=allow_failure(result))


if __name__ == "__main__":
    run_test_flow()
I expect this to run
test_1.submit
, fail twice, since the
sleep
is larger than the
timeout_seconds
, and then run the second
test_1.submit
But it does not appear to be working it does not run the second
test_1.submit
@User, @User do you have thoughts on this ?
j
I just tested your code with Prefect 2.7.4 and when I changed the
timeout_seconds=10
then it raised the IOError:
Copy code
File "/Users/jeffhale/Desktop/prefect/allow_failure_slack_example.py", line 10, in test_1
    raise IOError("Raising some error")
OSError: Raising some error
Does the longer timeout fix it for you?
y
I use Prefect 2.7.4 as well I get the timeout error, but it never gets to the second run, with the
wait_for
, I do not get the
raise IOError('Raising some error')
error
if you change the timeout to 10sec, it does not fail the first task,
result = test_1.submit(True, True)
and then you get the
Raising some error
but the point of this test is to see if the second task runs when the first task fails with to many retries
j
Gotcha, YD. The code works as expected without retries, but not when there are retries. I see the same behavior. Looks like a bug to me. Are you able to open a bug report in the repo?
y