Skip to main content

Task authoring and execution

Authoring and executing Flyte tasks

The problem tasks solve

When you write a workflow for the Flyte platform, your Python functions need to travel: their interfaces get registered with Flyte Admin, and their bodies get re-run later inside a container on a cluster — possibly days after you wrote them, with no access to your local module state. Flytekit solves this with a small class hierarchy plus a decorator, so that a plain, type-annotated function becomes a serializable, re-hydratable unit of work.

The user-facing entry point is the @task decorator from flytekit.core.decorators (implemented in flytekit.core.task):

from flytekit import task

@task
def my_func(a: int) -> str:
return str(a)

Under the hood, the decorator constructs a PythonFunctionTask (flytekit/core/python_function_task.py), which auto-detects the function's name, module, and typed interface:

"In the above code, the name of the function, the module, and the interface (inputs = int and outputs = str) will be auto detected."

You can then