Write your first Flyte workflow¶
By the end of this getting started guide you’ll be familiar with how easy it is to author a Flyte workflow and run it locally.
Estimated time to complete: <3 minutes.
Prerequisites¶
Ensure that you have git installed.
- Let us make a virutal environment (recommended) - and then install flytekit using
--pre
is used because we are currently using the beta version of flytekit 0.16.0, this introduces a completely new SDK for authoring workflowspip install --pre flytekit
Now we will use the
flytekit-python-template
repo to create our own git repository calledflyteexamples
git clone git@github.com:flyteorg/flytekit-python-template.git flyteexamples cd flyteexamples rm -rf .git git init
Flyte Tasks and Workflows¶
Let’s take a look at the example workflow found in myapp/workflows/example.py
from flytekit import task, workflow
@task
def greet(name: str) -> str:
return f"Hello, {name}"
@workflow
def hello_world(name: str = "world") -> str:
greeting = greet(name=name)
return greeting
The most basic Flyte primitive is a task Flyte tasks are units of work that can be composed in a workflow
You can call this task
greet(name="world")
and iterate locally before adding it to part of a larger overall workflow.
Similarly, you can call this workflow
hello_world(name=...)
and iterate locally before moving on to register it with Flyte.
Tip
Every invocation of a Flyte workflow requires specifying keyword arguments as in the example - hello_world(name="name")
. Calling the workflow without the keyword name
will raise an AssertionError
.