AsyncFunctionTaskTemplate
A task template that wraps an asynchronous functions. This is automatically created when an asynchronous function is decorated with the task decorator.
Attributes
| Attribute | Type | Description |
|---|---|---|
| func | F | The underlying asynchronous or synchronous function wrapped by this task template. |
| plugin_config | Optional[Any] = None | This is used to pass plugin specific configuration. |
| debuggable | bool = True | Boolean flag indicating whether the task can be debugged during execution. |
| task_resolver | Optional[Any] = None | The resolver used to locate and load the task code during execution if no code bundle is provided. |
Constructor
Signature
def AsyncFunctionTaskTemplate()
Methods
source_file()
@classmethod
def source_file() - > Optional[str]
Returns the source file of the function, if available. This is useful for debugging and tracing.
Returns
| Type | Description |
|---|---|
Optional[str] | The absolute file path to the Python source file containing the wrapped function, or None if it cannot be determined. |
json_schema()
@classmethod
def json_schema() - > Dict[str, Any]
JSON schema for the task inputs, following the Flyte standard.
Returns
| Type | Description |
|---|---|
Dict[str, Any] | A dictionary representing the JSON schema of the task's input interface. |
forward()
@classmethod
def forward(
args: P.args,
kwargs: P.kwargs
) - > Coroutine[Any, Any, R]| R
Invokes the wrapped function directly during local execution, returning either a coroutine or the direct result.
Parameters
| Name | Type | Description |
|---|---|---|
| args | P.args | Positional arguments to pass to the wrapped function. |
| kwargs | P.kwargs | Keyword arguments to pass to the wrapped function. |
Returns
| Type | Description |
|---|---|
| `Coroutine[Any, Any, R] | R` |
execute()
@classmethod
def execute(
args: P.args,
kwargs: P.kwargs
) - > R
This is the execute method that will be called when the task is invoked. It will call the actual function.
Parameters
| Name | Type | Description |
|---|---|---|
| args | P.args | Positional arguments required by the task's function. |
| kwargs | P.kwargs | Keyword arguments required by the task's function. |
Returns
| Type | Description |
|---|---|
R | The result of the task execution after running pre-execution hooks, the function itself, and post-execution hooks. |
container_args()
@classmethod
def container_args(
serialize_context: [SerializationContext](../models/serializationcontext.md?sid=flyte_models_serializationcontext)
) - > List[str]
Generates the command-line arguments required to execute this task within a container, including input/output paths and resolver details.
Parameters
| Name | Type | Description |
|---|---|---|
| serialize_context | [SerializationContext](../models/serializationcontext.md?sid=flyte_models_serializationcontext) | The context object containing paths, image information, and code bundle details needed for serialization. |
Returns
| Type | Description |
|---|---|
List[str] | A list of string arguments used to construct the container entrypoint command. |