Skip to content

Getting started

In this section, we give a quick introduction to writing and running Union workflows on your local machine.

To get started, you will need to do the following:

Create a "Hello, world!" workflow

To create an example workflow file, copy the following into a file called example.py:

python
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

Tasks and workflows

In this example, the file example.py contains a task and a workflow. These are simply Python functions decorated with the @task and @workflow decorators, respectively. The workflow is the top-level construct which you run. The workflow, in turn, invokes the task.

2. Run the example workflow in a local Python environment

Run the workflow with pyflyte run. The syntax is:

shell
$ pyflyte run <script_path> <task_or_workflow_name>

In this case:

shell
$ pyflyte run example.py hello_world_wf

You should see the following output:

Running Execution on local.
Hello, world!

Since the @workflow function takes an argument called name, you can also pass that in:

shell
$ pyflyte run example.py hello_world_wf --name Ada

Then, you should see the following output:

Running Execution on local.
Hello, Ada!

Next steps

In the following sections, we will walk through setting up a simple but production-level Union project and deploying it to your Union instance in the cloud.