---
title: "Runner"
description: "Define task registrations for a Python workflow project."
image: "https://tilebox.com/images/tilebox-docs-social-preview.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://tilebox.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Runner

import ParamField from "@docs/components/ParamField.astro";

```python
class Runner(
    *,
    tasks: list[type[Task]] | None = None,
    cache: JobCache | None = None,
    context: type[RunnerContext] | None = None,
)
```

Define task registrations for a Python workflow project.

A `Runner` object is a reusable definition. Use it for direct execution by connecting it to a [`Client`](/docs/api-reference/python/tilebox.workflows/Client), or reference it from `tilebox.workflow.toml` so release runners can load the same task registrations from a workflow release.

## Parameters

**tasks**

type: list[type[Task]] | None

A list of task classes this runner can execute.

**cache**

type: JobCache | None

Optional [job cache](/docs/workflows/run-and-inspect/caches) used by tasks executed by this runner.

**context**

type: type[RunnerContext] | None

Optional runner context class to instantiate for tasks executed by this runner.

## Example

```python
from tilebox.workflows import Runner
from tilebox.workflows.cache import (
    LocalFileSystemCache,
)

from my_workflow.tasks import MyRootTask, MySubtask


runner = Runner(
    tasks=[MyRootTask, MySubtask],
    cache=LocalFileSystemCache(),
)
```

You can also register tasks after creating a runner:

```python
runner = Runner(cache=LocalFileSystemCache())
runner.register(MyRootTask)
runner.register(MySubtask)
```

Use the same object for direct execution:

```python
from tilebox.workflows import Client

from my_workflow.runner import runner


runner.connect_to(
    Client(), cluster="dev-cluster"
).run_forever()
```

Or reference it from `tilebox.workflow.toml` for release execution:

```toml
[workflow]
slug = "my-workflow"
root = "."
runner = "my_workflow.runner:runner"
```

Source: https://tilebox.com/docs/api-reference/python/tilebox.workflows/Runner/index.mdx
