Zohaa Qamar
11/29/2021, 2:07 PMSylvain Hazard
11/29/2021, 2:10 PMfrom prefect.engine.signals import FAIL
from prefect import task
@task
def my_task():
if condition:
raise FAIL("Fail Message")
This will have the task enter a failed state.Sylvain Hazard
11/29/2021, 2:10 PMZohaa Qamar
11/29/2021, 2:13 PMSylvain Hazard
11/29/2021, 2:13 PMSylvain Hazard
11/29/2021, 2:14 PMmax_retries=1
Zohaa Qamar
11/29/2021, 2:14 PMZohaa Qamar
11/29/2021, 2:17 PMSylvain Hazard
11/29/2021, 2:21 PM@task
def my_task:
if condition:
raise AttributeError("something went wrong")
Anna Geller
from prefect.engine.signals import ENDRUN
from prefect import task
@task
def my_task():
if condition:
raise ENDRUN("Exiting the task execution...")
Zohaa Qamar
11/29/2021, 2:25 PMAnna Geller
from prefect import task, Flow, case
@task(log_stdout=True)
def end_flow():
print("Ending the flow run due to the XXX")
with Flow("conditional-logic") as flow:
cond = check_condition()
with case(cond, True):
val = t1()
val2 = t2()
t3(val, val2)
with case(cond, False):
end_flow()
Anna Geller
Zohaa Qamar
11/29/2021, 2:37 PM