Quickstart
Let’s get you up and running with your first workflow.
What you’ll need
- Python 3.10+ in a virtual environment
- Access to a Union/Flyte instance (you’ll need the URL and a project where you can run workflows)
Install the SDK
Install the flyte package (currently in beta, so prerelease flag required):
pip install --pre flyteVerify it worked:
flyte --versionConfigure your connection
Create a config file pointing to your Union instance. Replace the placeholder values with your actual endpoint and project name:
flyte create config \
--endpoint my-org.my-company.com \
--domain development \
--project my-project \
--builder remoteThis creates ./.flyte/config.yaml in your current directory. See
Setting up a configuration file for more options.
flyte get config to check which configuration is currently active.Write your first workflow
Create hello.py:
# hello.py
import flyte
# The `hello_env` TaskEnvironment is assigned to the variable `env`.
# It is then used in the `@env.task` decorator to define tasks.
# The environment groups configuration for all tasks defined within it.
env = flyte.TaskEnvironment(name="hello_env")
# We use the `@env.task` decorator to define a task called `fn`.
@env.task
def fn(x: int) -> int: # Type annotations are required
slope, intercept = 2, 5
return slope * x + intercept
# We also use the `@env.task` decorator to define another task called `main`.
# This is the is the entrypoint task of the workflow.
# It calls the `fn` task defined above multiple times using `flyte.map`.
@env.task
def main(x_list: list[int] = list(range(10))) -> float:
y_list = list(flyte.map(fn, x_list)) # flyte.map is like Python map, but runs in parallel.
y_mean = sum(y_list) / len(y_list)
return y_mean
Here’s what’s happening:
TaskEnvironmentspecifies configuration for your tasks (container image, resources, etc.)@env.taskturns Python functions into tasks that run remotely- Both tasks share the same
env, so they’ll have identical configurations
Run it
With your config file in place:
.
├── hello.py
└── .flyte
└── config.yamlRun the workflow:
flyte run hello.py mainThis packages your code and sends it to your Union/Flyte instance for execution.
See the results
You’ll see output like:
cg9s54pksbjsdxlz2gmc
https://my-instance.example.com/v2/runs/project/my-project/domain/development/cg9s54pksbjsdxlz2gmc
Run 'a0' completed successfully.Click the link to view your run in the UI:
Next steps
Now that you’ve run your first workflow:
- Why Flyte?: Understand what makes Flyte different
- Flyte basics: Learn core concepts through working examples