Connect tasks into a directed acyclic graph using the @workflow decorator.
Workflows link multiple tasks together. They are written as Python functions decorated with @workflow, but it is important to understand how they differ from tasks.
Tasks
Execute at run time — on a Kubernetes pod, in a query engine, or on a hosted service.
Workflows
Execute at registration time — the workflow body builds the DAG. No computation happens inside a workflow.
Registration involves uploading the serialized code to the Flyte backend so the workflow can be triggered.
The @workflow decorator wraps task calls in lazily evaluated promises. When the workflow body runs at registration time:
Each task call returns a Promise object — not the actual output value.
Promises can be passed to downstream tasks as inputs.
Promises cannot be inspected or manipulated inside the workflow body.
Actual values are only available when the workflow executes.
Because workflow inputs are also promises, you can only pass them directly into tasks or other workflows — you cannot branch on them with if/else logic. Use dynamic workflows for conditional logic over materialized inputs.
Flyte stores docstrings in FlyteAdmin and displays them in the UI. You can use any Python docstring style.
Sphinx-style docstring
documenting_workflows.py
from flytekit import workflow@workflowdef sphinx_docstring_wf(x: list[int] = [-3, 0, 3], y: list[int] = [7, 4, -2]) -> float: """ Slope and intercept of a regression line. This workflow computes the slope and intercept of a regression line using the provided x and y data points. :param x: List of x-values. :param y: List of y-values. :return: The intercept of the regression line. """ ...
NumPy-style docstring
documenting_workflows.py
from flytekit import workflow@workflowdef numpy_docstring_wf(x: list[int] = [-3, 0, 3], y: list[int] = [7, 4, -2]) -> float: """ Slope and intercept of a regression line. This workflow computes the slope and intercept of a regression line using the provided x and y data points. Parameters ---------- x : list[int] List of x-values. y : list[int] List of y-values. Returns ------- float The intercept of the regression line. """ ...
Google-style docstring
documenting_workflows.py
from flytekit import workflow@workflowdef google_docstring_wf(x: list[int] = [-3, 0, 3], y: list[int] = [7, 4, -2]) -> float: """ Slope and intercept of a regression line. This workflow computes the slope and intercept of a regression line using the provided x and y data points. Args: x (list[int]): List of x-values. y (list[int]): List of y-values. Returns: float: The intercept of the regression line. """ ...
The short description (first line of the docstring) appears on the workflow list page in the UI. The full description is visible when you open the workflow.