Inherits from namedtuple for unpacking support in another tools.
Source code in src/prefect/utilities/annotations.py
9101112131415161718192021222324252627282930
classBaseAnnotation(namedtuple("BaseAnnotation",field_names="value"),ABC,Generic[T]):""" Base class for Prefect annotation types. Inherits from `namedtuple` for unpacking support in another tools. """defunwrap(self)->T:returnself.valuedefrewrap(self,value:T)->"BaseAnnotation[T]":returntype(self)(value)def__eq__(self,other:object)->bool:ifnottype(self)==type(other):returnFalsereturnself.unwrap()==other.unwrap()def__repr__(self)->str:returnf"{type(self).__name__}({self.value!r})"
Indicates that the upstream run for this input can be failed.
Generally, Prefect will not allow a downstream run to start if any of its inputs
are failed. This annotation allows you to opt into receiving a failed input
downstream.
If the input is from a failed run, the attached exception will be passed to your
function.
Source code in src/prefect/utilities/annotations.py
46474849505152535455565758
classallow_failure(BaseAnnotation[T]):""" Wrapper for states or futures. Indicates that the upstream run for this input can be failed. Generally, Prefect will not allow a downstream run to start if any of its inputs are failed. This annotation allows you to opt into receiving a failed input downstream. If the input is from a failed run, the attached exception will be passed to your function. """
Simple wrapper to mark an expression as a different type so it will not be coerced
by Prefect. For example, if you want to return a state from a flow without having
the flow assume that state.
quote will also instruct prefect to ignore introspection of the wrapped object
when passed as flow or task parameter. Parameter introspection can be a
significant performance hit when the object is a large collection,
e.g. a large dictionary or DataFrame, and each element needs to be visited. This
will disable task dependency tracking for the wrapped object, but likely will
increase performance.
classquote(BaseAnnotation[T]):""" Simple wrapper to mark an expression as a different type so it will not be coerced by Prefect. For example, if you want to return a state from a flow without having the flow assume that state. quote will also instruct prefect to ignore introspection of the wrapped object when passed as flow or task parameter. Parameter introspection can be a significant performance hit when the object is a large collection, e.g. a large dictionary or DataFrame, and each element needs to be visited. This will disable task dependency tracking for the wrapped object, but likely will increase performance. ``` @task def my_task(df): ... @flow def my_flow(): my_task(quote(df)) ``` """defunquote(self)->T:returnself.unwrap()
Indicates that this input should be sent as-is to all runs created during a mapping
operation instead of being split.
Source code in src/prefect/utilities/annotations.py
3334353637383940414243
classunmapped(BaseAnnotation[T]):""" Wrapper for iterables. Indicates that this input should be sent as-is to all runs created during a mapping operation instead of being split. """def__getitem__(self,_)->T:# Internally, this acts as an infinite array where all items are the same valuereturnself.unwrap()