Ross Timm
07/27/2021, 8:11 PMKevin Kho
ENDRUN signal.Ross Timm
07/27/2021, 10:43 PMRoss Timm
07/28/2021, 3:11 PMENDRUN signal in the task it just cancels the task and has a successful state for the flow. So if I want to cancel the task AND cancel the flow what's the best accomplish thatKevin Kho
Ross Timm
07/28/2021, 3:26 PMKevin Kho
from prefect import Flow, task, unmapped
import time
from prefect.engine.signals import ENDRUN, FAIL
from prefect.engine.state import Failed
@task
def aws_list_files(a):
if a == 1:
raise ENDRUN(state=Failed())
return a
with Flow("xxx") as flow:
aws_list_files(1)
flow.run()Ross Timm
07/28/2021, 3:32 PMFailed() I do Cancelled()Kevin Kho
Kevin Kho
ENDRUN is causing the Flow to fail. In your case, I think what is happening is that you have other tasks not related to the task that raised the ENDRUN. These are your reference tasks that determine the success or failure of the flow. You can explicitly include the task that raises ENDRUN as a reference task like this:
from prefect import Flow, task, unmapped
import time
from prefect.engine.signals import ENDRUN, FAIL
from prefect.engine.state import Failed
@task
def aws_list_files(a):
time.sleep(1)
if a == 1:
raise ENDRUN(state=Failed())
return a
with Flow("xxx") as flow:
a = aws_list_files(1)
b = aws_list_files(2, upstream_tasks=[a])
c = aws_list_files(2)
flow.set_reference_tasks([a,c])
flow.run()
In this example, if I set my reference task to c only, the flow succeeds even if a and b fail. I think in your case, it’s a matter of explicitly making the ENDRUN task an upstream_task or setting it as a reference task.Kevin Kho
ENDRUN should stop all processing whatsoever. I’m a bit unclear on this.Ross Timm
07/28/2021, 3:47 PMKevin Kho
c still runs even if the ENDRUN signal was raised so I’ll ask the team about that partRoss Timm
07/28/2021, 3:51 PMKevin Kho
Ross Timm
07/28/2021, 5:08 PMKevin Kho
Kevin Kho
ENDRUN only ends the current task but not the flow run. The docs will be updated to reflect this.Ross Timm
07/28/2021, 5:23 PMRoss Timm
07/28/2021, 5:26 PMKevin Kho
raise FAIL explicitly instead of ENDRUN, but I think the issue that the task is failing but the terminal tasks are succeeding.Kevin Kho