Tri
10/28/2024, 4:22 PMMarvin
10/28/2024, 4:22 PMpython
from prefect import flow, task
@task
def always_fails_task():
raise ValueError("I fail successfully")
@task
def always_succeeds_task():
print("I'm fail-safe!")
return "success"
@flow
def always_succeeds_flow():
x = always_fails_task.submit().result(raise_on_failure=False) # This allows the flow to continue despite the failure
y = always_succeeds_task.submit(wait_for=[x])
return y
if __name__ == "__main__":
always_succeeds_flow()
In this example, the always_fails_task
uses result(raise_on_failure=False)
to bypass raising an exception and continue with the always_succeeds_task
.
For more information, you can refer to the Prefect 3.x documentation on writing flows.