Skip to main content
Flyte tasks are the core building blocks of larger, more complex workflows. Workflows compose multiple tasks — or other workflows — into meaningful steps of computation to produce a useful set of outputs. This page walks you through writing the simplest possible Flyte workflow: a single task that returns "Hello, World!".

Prerequisites

Install flytekit, the Python SDK for Flyte:
pip install flytekit

Write the workflow

1

Import task and workflow

Import task and workflow from the flytekit library:
hello_world.py
from flytekit import task, workflow
2

Define a task

Use the @task decorator to define a function that produces the string "Hello, World!". All inputs and outputs must be annotated with their types:
hello_world.py
@task
def say_hello(name: str) -> str:
    return f"Hello, {name}!"
The @task decorator marks a regular Python function as a Flyte task. Flyte runs each task in its own container on a Kubernetes pod.
3

Define a workflow

Use the @workflow decorator to wire tasks together. Handle the output of a task the same way you would in regular Python — store it in a variable and return it:
hello_world.py
@workflow
def hello_world_wf(name: str = "world") -> str:
    res = say_hello(name=name)
    return res
Workflow bodies do not execute at run time. They execute at registration time to build a DAG of task dependencies. Actual computation happens inside tasks.
4

Run locally

You can run the workflow by calling it like a regular Python function:
hello_world.py
if __name__ == "__main__":
    print(hello_world_wf(name="world"))
Or use the pyflyte run CLI command:
pyflyte run hello_world.py hello_world_wf --name world
Expected output:
Hello, world!

Complete example

hello_world.py
from flytekit import task, workflow


@task
def say_hello(name: str) -> str:
    return f"Hello, {name}!"


@workflow
def hello_world_wf(name: str = "world") -> str:
    res = say_hello(name=name)
    return res


if __name__ == "__main__":
    print(hello_world_wf(name="world"))

Run on a Flyte cluster

To execute the workflow remotely on a Flyte cluster, add the --remote flag:
pyflyte run --remote hello_world.py hello_world_wf --name world
The full source for this example is available in the Flytesnacks repository.

Next steps

Tasks

Learn how to define tasks with type annotations, resource requests, caching, retries, and more.

Workflows

Connect multiple tasks together and pass data between them.

Launch plans

Schedule and share workflows with fixed or default inputs.

Build docs developers (and LLMs) love