---
title: "Task"
description: "Create a workflow task by inheriting from the automatically dataclass-decorated base class."
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.

# Task

import { Fragment } from "astro/jsx-runtime";

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

```python
class Task:
    def execute(context: ExecutionContext) -> Awaitable[None] | None

    @staticmethod
    def identifier() -> tuple[str, str]
```

Base class for Tilebox workflows [tasks](/docs/workflows/concepts/tasks). Inherit from this class to create a task.
Inheriting also automatically applies the dataclass decorator.

## Methods

```python
def Task.execute(context: ExecutionContext) -> Awaitable[None] | None
```

The entry point for the execution of the task. Define it as either `def execute(...) -> None` or `async def execute(...) -> None`. The runner waits for an asynchronous method to complete.

```python
@staticmethod
def Task.identifier() -> tuple[str, str]
```
Override a task identifier and specify its version. If not overridden, the identifier of a task defaults to the class name, and the version to `v0.0`.

## Task Input Parameters

```python
class MyTask(Task):
    message: str
    value: int
    data: dict[str, int]
```

Optional task [input parameters](/docs/workflows/concepts/tasks#input-parameters), defined as annotated class attributes. See [Python task inputs](/docs/sdks/python/task-inputs) for the supported types and their package requirements.

<h2 id="request-example">Usage example</h2>

```python
from tilebox.workflows import (
    Task,
    ExecutionContext,
)


class MyFirstTask(Task):
    def execute(self, context: ExecutionContext):
        print(f"Hello World!")

    @staticmethod
    def identifier() -> tuple[str, str]:
        return (
            "tilebox.workflows.MyTask",
            "v3.2",
        )


class MyFirstParameterizedTask(Task):
    name: str
    greet: bool
    data: dict[str, str]

    def execute(self, context: ExecutionContext):
        if self.greet:
            print(f"Hello {self.name}!")
```

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