# Signals
These Exceptions, when raised, are used to signal state changes when tasks or flows are running. Signals are used in TaskRunners and FlowRunners as a way of communicating the changes in states.
# ENDRUN
An ENDRUN exception is used to indicate that all state processing should stop. The pipeline result should be the state contained in the exception.
Args:
state (State)
: the state that should be used as the result of the Runner's run
# FAIL
Indicates that a task failed.
Args:
message (Any, optional)
: Defaults toNone
. A message about the signal.*args (Any, optional)
: additional arguments to pass to this Signal's associated state constructor**kwargs (Any, optional)
: additional keyword arguments to pass to this Signal's associated state constructor
# LOOP
Indicates that a task should loop with the provided result. Note that the result included in the LOOP
signal will be available in Prefect context during the next iteration under the key "task_loop_result"
.
Args:
message (Any, optional)
: Defaults toNone
. A message about the signal.*args (Any, optional)
: additional arguments to pass to this Signal's associated state constructor**kwargs (Any, optional)
: additional keyword arguments to pass to this Signal's associated state constructor
import prefect
from prefect import task, Flow
from prefect.engine.signals import LOOP
@task
def accumulate(x: int) -> int:
current = prefect.context.get("task_loop_result", x)
if current < 100:
# if current < 100, rerun this task with the task's loop result incremented
# by 5
raise LOOP(result=current + 5)
return current
with Flow("Looper") as flow:
output = accumulate(5)
flow_state = flow.run()
print(flow_state.result[output].result) # '100'
# TRIGGERFAIL
Indicates that a task trigger failed.
Args:
message (Any, optional)
: Defaults toNone
. A message about the signal.*args (Any, optional)
: additional arguments to pass to this Signal's associated state constructor**kwargs (Any, optional)
: additional keyword arguments to pass to this Signal's associated state constructor
# VALIDATIONFAIL
Indicates that a task's result validation failed.
Args:
message (Any, optional)
: Defaults toNone
. A message about the signal.*args (Any, optional)
: additional arguments to pass to this Signal's associated state constructor**kwargs (Any, optional)
: additional keyword arguments to pass to this Signal's associated state constructor
# SUCCESS
Indicates that a task succeeded.
Args:
message (Any, optional)
: Defaults toNone
. A message about the signal.*args (Any, optional)
: additional arguments to pass to this Signal's associated state constructor**kwargs (Any, optional)
: additional keyword arguments to pass to this Signal's associated state constructor
# RETRY
Used to indicate that a task should be retried.
Args:
message (Any, optional)
: Defaults toNone
. A message about the signal.*args (Any, optional)
: additional arguments to pass to this Signal's associated state constructor**kwargs (Any, optional)
: additional keyword arguments to pass to this Signal's associated state constructor
# SKIP
Indicates that a task was skipped. By default, downstream tasks will act as if skipped tasks succeeded.
Args:
message (Any, optional)
: Defaults toNone
. A message about the signal.*args (Any, optional)
: additional arguments to pass to this Signal's associated state constructor**kwargs (Any, optional)
: additional keyword arguments to pass to this Signal's associated state constructor
# PAUSE
Indicates that a task should not run and wait for manual execution.
Args:
message (Any, optional)
: Defaults toNone
. A message about the signal.*args (Any, optional)
: additional arguments to pass to this Signal's associated state constructor**kwargs (Any, optional)
: additional keyword arguments to pass to this Signal's associated state constructor
This documentation was auto-generated from commit n/a
on July 1, 2021 at 18:35 UTC