---
title: "ExecutionContext.submit_subtask"
description: "Submit a subtask from a currently executing task."
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.

# ExecutionContext.submit_subtask

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

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

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

```python
def ExecutionContext.submit_subtask(
  task: Task,
  depends_on: FutureTask | list[FutureTask] | None = None,
  cluster: str | None = None,
  max_retries: int = 0,
  optional: bool = False
) -> FutureTask
```

Submit a [subtask](/docs/workflows/concepts/tasks#task-composition-and-subtasks) from a currently executing task.

## Parameters

**task**

type: Task

The task to submit as a subtask.

**depends_on**

type: FutureTask | list[FutureTask] | None

An optional task or list of tasks already submitted within the same context that this subtask depends on.

**cluster**

type: str

An optional [cluster slug](/docs/workflows/concepts/clusters#managing-clusters) for running the subtask. If not provided, the subtask runs on the same cluster as the parent task.

**max_retries**

type: int

Specify the maximum number of [retries](/docs/workflows/concepts/tasks#retry-handling) for the subtask in case of failure. The default is 0.

**optional**

type: bool

Whether the subtask is [optional](/docs/workflows/concepts/tasks#optional-tasks). If `True`, the subtask will not fail the job if it fails. Tasks that depend on this task will still execute even if this task failed. The default is `False`.

## Returns

A `FutureTask` object that represents the submitted subtask. Can be used to set up dependencies between tasks.

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

```python
# within the execute method of a Task:
subtask = context.submit_subtask(MySubtask())
dependent_subtask = context.submit_subtask(
    MyOtherSubtask(), depends_on=[subtask]
)
gpu_task = context.submit_subtask(
    MyGPUTask(), cluster="gpu-cluster-slug"
)
flaky_task = context.submit_subtask(
    MyFlakyTask(), max_retries=5
)
optional_task = context.submit_subtask(
    MyOptionalTask(), optional=True
)
```

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