Prerequisites
- Python 3.8 or higher
pipavailable in your environment
Run your first workflow locally
Install flytekit
Install Flyte’s Python SDK:This installs both the
flytekit Python package and the pyflyte CLI tool.Write a Hello World workflow
Create a file called The
example.py with the following content:example.py
@task decorator marks a regular Python function as a Flyte task. The @workflow decorator marks a function as a Flyte workflow that composes those tasks.Run it locally with pyflyte run
Execute the workflow in your local Python environment:The initial arguments of You should see output like:
pyflyte run take the form path/to/script.py <task_or_workflow_name>. You can pass inputs as flags:Tasks and workflows must always be invoked with keyword arguments. Positional arguments are not supported.
Run on a local Flyte cluster
Theflytectl demo start command spins up a self-contained Flyte cluster running as a Docker container. This lets you test the full Flyte experience — including the FlyteConsole UI — without any cloud infrastructure.
Start the local demo cluster
Start a local Flyte cluster in a Docker container:This command pulls the Flyte sandbox image and starts FlyteAdmin, FlytePropeller, and FlyteConsole. The first run takes a few minutes to download images.Once started, you can access FlyteConsole at
http://localhost:30080/console.Docker must be installed and running before you run
flytectl demo start.The @task and @workflow decorators
The two core decorators you use every day in Flyte are@task and @workflow.
| Decorator | What it does |
|---|---|
@task | Marks a Python function as a Flyte task. When run on a cluster, each task executes in its own isolated container on a Kubernetes Pod. |
@workflow | Marks a function as a Flyte workflow. The workflow body is a DSL for building a DAG — it composes tasks but does not run computation itself. |
Workflow functions are compiled into execution graphs at registration time. The inputs and outputs of tasks within a workflow are promises (lazy references), not actual Python values. This is why you cannot use regular Python control flow like
if/else on task outputs inside a workflow.Using FlyteRemote to execute workflows programmatically
For larger projects where you have registered workflows to a cluster, use theFlyteRemote client instead of pyflyte run:
Next steps
Key Concepts
Understand tasks, workflows, launch plans, and projects in depth.
Tasks
Learn about task types, resource requests, caching, retries, and plugins.
Workflows
Learn how workflows build DAGs, handle promises, and support subworkflows.
User Guide
Go deeper into the Flyte SDK with data types, advanced composition, and more.