Skip to main content

AsyncFunctionTaskTemplate

A task template that wraps an asynchronous functions. This is automatically created when an asynchronous function is decorated with the task decorator.

Attributes

AttributeTypeDescription
funcFThe underlying asynchronous or synchronous function wrapped by this task template.
plugin_configOptional[Any] = NoneThis is used to pass plugin specific configuration.
debuggablebool = TrueBoolean flag indicating whether the task can be debugged during execution.
task_resolverOptional[Any] = NoneThe 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

TypeDescription
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

TypeDescription
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

NameTypeDescription
argsP.argsPositional arguments to pass to the wrapped function.
kwargsP.kwargsKeyword arguments to pass to the wrapped function.

Returns

TypeDescription
`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

NameTypeDescription
argsP.argsPositional arguments required by the task's function.
kwargsP.kwargsKeyword arguments required by the task's function.

Returns

TypeDescription
RThe 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

NameTypeDescription
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

TypeDescription
List[str]A list of string arguments used to construct the container entrypoint command.