|
| 1 | +--- |
| 2 | +title: Context.submit_subtasks |
| 3 | +icon: folder-gear |
| 4 | +--- |
| 5 | + |
| 6 | +```python |
| 7 | +def ExecutionContext.submit_subtasks( |
| 8 | + tasks: Sequence[Task], |
| 9 | + depends_on: list[FutureTask] = None, |
| 10 | + cluster: str | None = None, |
| 11 | + max_retries: int = 0, |
| 12 | + optional: bool = False |
| 13 | +) -> list[FutureTask] |
| 14 | +``` |
| 15 | + |
| 16 | +Submit multiple [subtasks](/workflows/concepts/tasks#subtasks-and-task-composition) from a currently executing task. Same as [submit_subtask](/api-reference/python/tilebox.workflows/ExecutionContext.submit_subtask), but accepts a sequence of tasks. |
| 17 | + |
| 18 | +## Parameters |
| 19 | + |
| 20 | +<ParamField path="tasks" type="Sequence[Task]"> |
| 21 | + The tasks to submit as subtasks. |
| 22 | +</ParamField> |
| 23 | + |
| 24 | +<ParamField path="depends_on" type="list[FutureTask]"> |
| 25 | + An optional list of tasks already submitted within the same context that the subtasks depend on. |
| 26 | +</ParamField> |
| 27 | + |
| 28 | +<ParamField path="cluster" type="str"> |
| 29 | + An optional [cluster slug](/workflows/concepts/clusters#managing-clusters) for running the subtasks. If not provided, the subtasks run on the same cluster as the parent task. |
| 30 | +</ParamField> |
| 31 | + |
| 32 | +<ParamField path="max_retries" type="int"> |
| 33 | + Specify the maximum number of [retries](/workflows/concepts/tasks#retry-handling) for the subtasks in case of failure. The default is 0. |
| 34 | +</ParamField> |
| 35 | + |
| 36 | +<ParamField path="optional" type="bool"> |
| 37 | + Whether the subtasks are [optional](/workflows/concepts/tasks#optional-tasks). If `True`, the subtasks will not fail the job if they fail. Tasks that depend on them will still execute even if they failed. The default is `False`. |
| 38 | +</ParamField> |
| 39 | + |
| 40 | +## Returns |
| 41 | + |
| 42 | +A list of `FutureTask` objects representing the submitted subtasks. Can be used to set up dependencies between tasks. |
| 43 | + |
| 44 | +<RequestExample> |
| 45 | +```python Python |
| 46 | +# within the execute method of a Task: |
| 47 | +subtasks = context.submit_subtasks([ |
| 48 | + MySubtask(i) for i in range(10) |
| 49 | +]) |
| 50 | +dependent_subtask = context.submit_subtask( |
| 51 | + MyOtherSubtask(), depends_on=subtasks |
| 52 | +) |
| 53 | +``` |
| 54 | +</RequestExample> |
0 commit comments