Hello, World!#
Letโs write a Flyte workflow()
that invokes a
task()
to generate the output โHello, World!โ.
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 some useful set of outputs or outcomes.
To begin, import task
and workflow
from the flytekit
library.
from flytekit import task, workflow
Define a task that produces the string โHello, World!โ.
Simply using the @task
decorator to annotate the Python function.
@task
def say_hello() -> str:
return "Hello, World!"
You can handle the output of a task in the same way you would with a regular Python function. Store the output in a variable and use it as a return value for a Flyte workflow.
@workflow
def hello_world_wf() -> str:
res = say_hello()
return res
Run the workflow by simply calling it like a Python function.
if __name__ == "__main__":
print(f"Running hello_world_wf() {hello_world_wf()}")
Next, letโs delve into the specifics of tasks, workflows and launch plans.