The tasks in this module can be used to represent constant values.
In general, users will not instantiate these tasks by hand; they will be automatically created
whenever the Prefect engine detects that a constant value is required. In many cases, Prefect
will not add
Constant tasks to the graph; optimizing them as flow-level attributes instead.
(value, name=None, **kwargs)[source]
The Constant class represents a single value in the flow graph.
value (Any): a constant value
name (str): a name for the constant; defaults to "Constant[(type(value))]" if not provided
**kwargs (Any): kwargs to pass to the Task constructor
Constant tasks are most commonly used to prevent Prefect from creating a large number of auto-generated tasks in Python collections.
run() method is called (with arguments, if appropriate) to run a task.
Note: The implemented
run method cannot have
*args in its signature. In addition, the following keywords are reserved:
If a task has arguments in its
run() method, these can be bound either by using the functional API and calling the task instance, or by using
In addition to running arbitrary functions, tasks can interact with Prefect in a few ways:
- Return an optional result. When this function runs successfully, the task is considered successful and the result (if any) can be made available to downstream tasks.
- Raise an error. Errors are interpreted as failure.
- Raise a signal. Signals can include
SKIP, etc. and indicate that the task should be put in the indicated state.
FAIL will lead to retries if appropriate
SUCCESS will cause the task to be marked successful
RETRY will cause the task to be marked for retry, even if
max_retries has been exceeded
SKIP will skip the task and possibly propogate the skip state through the flow, depending on whether downstream tasks have
This documentation was auto-generated from commit 4980691
on April 29, 2021 at 20:09 UTC