scott
01/09/2023, 6:50 PMtry ... catch
with Prefect 2 tasks, if it’s possible that is? I’d like to be able to skip a failed task and let downstream tasks proceed but it seems like a Failed task kills the entire flow. Or maybe I’m wrong?Andrew Huang
01/09/2023, 7:01 PMZanie
01/09/2023, 7:02 PMfrom prefect import task, flow, allow_failure
@task
def fail():
raise ValueError()
@task
def succeed(x):
return x
@flow
def example():
try:
fail()
except ValueError:
print("Ah it failed")
print("All good!")
state = fail(return_state=True)
if state.is_failed():
print("Ah it failed")
print("All good")
future = fail.submit()
try:
future.result()
except ValueError:
print("Ah it failed")
print("All good!")
return succeed(allow_failure(future))
example()
scott
01/09/2023, 7:13 PMshell_run_command
?Zanie
01/09/2023, 7:20 PMscott
01/09/2023, 7:40 PM