# Quickstart

Let's get you up and running with your first workflow on your local machine.

> **📝 Note**
>
> Want to try Flyte without installing anything? [Try Flyte 2 in your browser](https://flyte2intro.apps.demo.hosted.unionai.cloud/).

## What you'll need

- Python 3.10+ in a virtual environment

## Install the SDK

Install the `flyte` package:

```bash
pip install 'flyte[tui]'
```
> **📝 Note**
>
> We also install the `tui` extra to enable the terminal user interface.

Verify it worked:

```bash
flyte --version
```

Output:

```bash
Flyte SDK version: 2.*.*
```

## Configure

Create a config file for local execution. Runs will be persisted locally in a SQLite database.

```bash
flyte create config --local-persistence
```

This creates `.flyte/config.yaml` in your current directory. See [Setting up a configuration file](https://www.union.ai/docs/v2/union/user-guide/quickstart/connecting-to-a-cluster#configuration-file) for more options.

> **📝 Note**
>
> Run `flyte get config` to check which configuration is currently active.

## Write your first workflow

Create `hello.py`:

```python
# 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
```

*Source: https://github.com/unionai/unionai-examples/blob/main/v2/user-guide/getting-started/hello.py*

Here's what's happening:

- **`TaskEnvironment`** specifies configuration for your tasks (container image, resources, etc.)
- **`@env.task`** turns Python functions into tasks that run remotely
- Both tasks share the same `env`, so they'll have identical configurations

## Run it

Create a project directory and place your files there:

```
.
├── hello.py
└── .flyte
    └── config.yaml
```

> [!WARNING]
> Do not run `flyte run` from your home directory. Flyte packages the current directory when running remotely, so running from `$HOME` would attempt to bundle your entire home folder. Always work from a dedicated project directory.

Run the workflow:

```bash
flyte run --local hello.py main
```

This executes the workflow locally on your machine.

## See the results

You can see the run in the TUI by running:

```bash
flyte start tui
```

The TUI will open into the explorer view

![Explorer View](https://www.union.ai/docs/v2/union/user-guide/_static/images/user-guide/quickstart/explorer-tui.png)

To navigate to the run details, double-click it or press `Enter` to view the run details.

![Run Details View](https://www.union.ai/docs/v2/union/user-guide/_static/images/user-guide/quickstart/run-tui.png)

## Next steps

Now that you've run your first workflow:

- [**Core concepts**](https://www.union.ai/docs/v2/union/user-guide/quickstart/core-concepts/_index): Understand the core concepts of Flyte programming
- [**Running locally**](https://www.union.ai/docs/v2/union/user-guide/quickstart/running-locally): Learn about the TUI, caching, and other features that work locally
- [**Connecting to a cluster**](https://www.union.ai/docs/v2/union/user-guide/quickstart/connecting-to-a-cluster): Configure your environment for remote execution

---
**Source**: https://github.com/unionai/unionai-docs/blob/main/content/user-guide/quickstart.md
**HTML**: https://www.union.ai/docs/v2/union/user-guide/quickstart/
