# Batch contexts

This page describes contexts the [Batch workflow](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md) can use in expressions for calculating YAML attribute values.

## Batch Contexts

| Context name | Description                                                                                                                                                                                                            |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `flow`       | Information about the main workflow settings, defaults, etc. See [`flow` context](#flow-context) for details.                                                                                                          |
| `project`    | Information about the project. See [`project` context](#project-context) for details.                                                                                                                                  |
| `params`     | A mapping of global workflow parameters. For more information, see [`params` context.](#params-context)                                                                                                                |
| `env`        | Contains environment variables set in workflow defaults. For more information, see [`env` context](#env-context) .                                                                                                     |
| `tags`       | A set of job tags set in workflow defaults. See [`tags` context](#tags-context) for details.                                                                                                                           |
| `volumes`    | Contains a mapping of volume definitions. For more information, see [`volumes` context](#volumes-context).                                                                                                             |
| `images`     | Contains a mapping of docker images from [workflow config](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#images). See [`images` context](#images-context) for details.                          |
| `strategy`   | Contains information about strategies from [flow defaults](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#defaults). See [`strategy` context](#strategy-context) for details.                    |
| `matrix`     | Contains combination data generated by the [`tasks.strategy.matrix`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#tasks-strategy-matrix). See [`matrix` context](#matrix-context) for details. |
| `needs`      | Contains outputs generated by tasks from [`tasks.needs`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#tasks-needs). See [`needs` context](#needs-context) for details.                         |
| `git`        | A mapping of the flow's workspace to a git repository. For more information, see [`git` context](#git-context).                                                                                                        |

### `flow` context

The `flow`context contains information about the workflow: its ID, title, etc.

| Property name     | Type        | Description                                                                                                                                                                                                                                                                                                                                           |
| ----------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `flow.flow_id`    | `str`       | The workflow's ID. It is automatically generated based on the workflow's YAML filename with a dropped suffix. You can override the property by setting the [`flow.id`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#id) attribute.                                                                                            |
| `flow.project_id` | `str`       | The project's ID. It is automatically generated based on the name of the flow folder. You can override it using [`project.id`](/index/apolo-flow-reference/workflow-syntax/project-configuration-syntax.md#id) attribute. Check [the project configuration](/index/apolo-flow-reference/workflow-syntax/project-configuration-syntax.md) for details. |
| `flow.workspace`  | `LocalPath` | A path to the workspace (the root folder of the flow).                                                                                                                                                                                                                                                                                                |
| `flow.title`      | `str`       | The workflow's title. Set the [`flow.title`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#title) attribute to override the auto-calculated value.                                                                                                                                                                             |
| `flow.username`   | `str`       | Name of user who executed the workflow run.                                                                                                                                                                                                                                                                                                           |

### `project` context

The `project`context contains information about the project: its ID, owner, etc.

| Property name          | Type  | Description                                                                                                                                                                                                                                                                                                                                                                                                    |
| ---------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `project.id`           | `str` | The project's ID. It is automatically generated based on the name of the flow folder. You can override it using [`project.id`](/index/apolo-flow-reference/workflow-syntax/project-configuration-syntax.md#id) attribute. Check [the project configuration](/index/apolo-flow-reference/workflow-syntax/project-configuration-syntax.md) for details. This context property is an alias to `flow.project_id` . |
| `project.owner`        | `str` | The project's owner. See also: [the project configuration](/index/apolo-flow-reference/workflow-syntax/project-configuration-syntax.md#owner).                                                                                                                                                                                                                                                                 |
| `project.project_name` | `str` | The platform project name. Set the [project.project\_name](/index/apolo-flow-reference/workflow-syntax/project-configuration-syntax.md#project_name) attribute to override the auto-calculated value.                                                                                                                                                                                                          |

### `params` context

Parameter described in the [`params` attribute](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#params) .

| Property name         | Type  | Description                        |
| --------------------- | ----- | ---------------------------------- |
| `params.<param-name>` | `str` | The value of a specific parameter. |

### `env` context

The `env` context contains environment variables that have been set in the [workflow defaults](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#defaults-env). For more information about setting environment variables in your workflow, see "[Batch workflow syntax](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#batch-workflow)."

The `env` context syntax allows you to use the value of an environment variable in your workflow file. If you want to use the value of an environment variable inside a job, use your operating system's standard method for reading environment variables.

| Property name    | Type  | Description                                   |
| ---------------- | ----- | --------------------------------------------- |
| `env.<env-name>` | `str` | The value of a specific environment variable. |

### `tags` context

A set of job tags.

Tags available in this context are combined from system tags (`project:<project-id>`, `flow:<flow-id>`, `task:<task-id>`), and flow default tags (see [`defaults.tags` attribute](/index/apolo-flow-reference/workflow-syntax/live-workflow-syntax.md#defaults-tags)).

| Property name | Type       | Description                                                                  |
| ------------- | ---------- | ---------------------------------------------------------------------------- |
| `tags`        | `set[str]` | This context changes for each job. You can access this context from any job. |

### `volumes` context

Contains information about volumes defined in the [`volumes` section ](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#volumes)of a *batch* workflow.

| Property name                         | Type                  | Description                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `volumes.<volume-id>.id`              | `str`                 | The volume definition identifier. For more information, see [`volumes.<volume-id>` section](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#volumes-less-than-volume-id-greater-than).                                                                                                                              |
| `volumes.<volume-id>.remote`          | `URL`                 | <p>Remote volume URI, e.g. <code>storage:path/to</code>.<br>For more information, see <a href="/pages/o41m4O4yqiFR9FwnivCR#volumes-less-than-volume-id-greater-than-remote"><code>volumes.\<volume-id>.remote</code> attribute</a>.</p>                                                                                                  |
| `volumes.<volume-id>.mount`           | `RemotePath`          | <p>The path inside a job by which the volume should be mounted.</p><p>For more information, see <a href="/pages/o41m4O4yqiFR9FwnivCR#volumes-less-than-volume-id-greater-than-mount"><code>volumes.\<volume-id>.mount</code> attribute</a>.</p>                                                                                          |
| `volumes.<volume-id>.read_only`       | `bool`                | <p><code>True</code> if the volume is mounted in read-only mode, <code>False</code> otherwise.</p><p>For more information, see <a href="/pages/o41m4O4yqiFR9FwnivCR#volumes-less-than-volume-id-greater-than-read_only"><code>volumes.\<volume-id>.read\_only</code> attribute</a>.</p>                                                  |
| `volumes.<volume-id>.local`           | `None`                | In *batch* workflows, this property is always `None`.                                                                                                                                                                                                                                                                                    |
| `volumes.<volume-id>.full_local_path` | `LocalPath` or `None` | Full version of `local` property.                                                                                                                                                                                                                                                                                                        |
| `volumes.<volume-id>.ref`             | `str`                 | <p>A volume reference that can be used as a <a href="/pages/o41m4O4yqiFR9FwnivCR#task-volumes"><code>task.volumes</code> item</a>. The calculated value looks like <code>storage:path/to:/mnt/path:rw</code>.</p><p>The value is assembled from the <code>remote</code>, <code>mount</code>, and <code>read\_only</code> properties.</p> |
| `volumes.<volume-id>.ref_ro`          | `str`                 | Like `ref` but *read-only* mode is enforced.                                                                                                                                                                                                                                                                                             |
| `volumes.<volume-id>.ref_rw`          | `str`                 | Like `ref` but *read-write* mode is enforced.                                                                                                                                                                                                                                                                                            |

### `images` context

Contains information about images defined in the [`images` section](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#images) of a *batch* workflow.

| Property name                            | Type             | Description                                                                                                                                                                                            |
| ---------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `images.<image-id>.id`                   | `str`            | The image definition identifier. For more information, see [`images.<image-id>`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#images-less-than-image-id-greater-than) section. |
| `images.<image-id>.ref`                  | `str`            | The image reference. For more information, see [`images.<image-id>.ref`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#images-less-than-image-id-greater-than-ref) attribute.   |
| `images.<image-id>.context`              | `None`           | In *batch* workflows, this property is always `None`.                                                                                                                                                  |
| `images.<image-id>.full_context_path`    | `None`           | In *batch* workflows, this property is always `None`.                                                                                                                                                  |
| `images.<image-id>.dockerfile`           | `None`           | In *batch* workflows, this property is always `None`.                                                                                                                                                  |
| `images.<image-id>.full_dockerfile_path` | `None`           | In *batch* workflows, this property is always `None`.                                                                                                                                                  |
| `images.<image-id>.build_args`           | `list[str]`      | In *batch* workflows, this property is always `[]`(empty list).                                                                                                                                        |
| `images.<image-id>.env`                  | `dict[str, str]` | In *batch* workflows, this property is always `{}`(empty dict).                                                                                                                                        |
| `images.<image-id>.volumes`              | `list[str]`      | In *batch* workflows, this property is always `[]`(empty list).                                                                                                                                        |

### `strategy` context

Contains information about some strategies of execution set in the [flow defaults](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#defaults).

| Property name           | Type   | Description                                                                                                                                                                                                                   |
| ----------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `strategy.fail_fast`    | `bool` | Task failure processing strategy. For more information, see [`defaults.fail_fast`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#defaults-fail_fast) attribute.                                        |
| `strategy.max_parallel` | `int`  | The maximum number of tasks that can be executed at the same time. For more information, see [`defaults.max_parallel`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#defaults-max_parallel) attribute. |

### `matrix` context

Contains parameters from a combination generated by the [`tasks.strategy.matrix`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#tasks-strategy-matrix) attribute.

| Property name         | Type                                          | Description                                             |
| --------------------- | --------------------------------------------- | ------------------------------------------------------- |
| `matrix.<param-name>` | `bool` or `int` or `float` or `str` or `None` | The matrix parameter value for the current combination. |

### `needs` context

Contains outputs generated by tasks that were specified in the [`tasks.needs`](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax.md#tasks-needs) attribute. Refer to the [`set-output` command](/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax/batch-workflow-commands.md#set-output-command) reference to learn how to generate outputs.

| Property name                           | Type  | Description                                                                                                                  |
| --------------------------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------- |
| `needs.<task-id>.result`                | `str` | State of the completed task `<task-id>`. Can be one of the following: `"succedded"`, `"failed"`, `"cancelled"`, `"skipped"`. |
| `needs.<task-id>.outputs.<output-name>` | `str` | The value of the `<output-name>` output produced by the `<task-id>` task.                                                    |

### `git` context

The `git` context contains a mapping of your flow's workspace to a git repository.

This context can only be used if the flow's workspace is inside some git repository.

| Property name | Type        | Description                                    |
| ------------- | ----------- | ---------------------------------------------- |
| `git.sha`     | `str`       | SHA of the current commit.                     |
| `git.branch`  | `str`       | Name of the current branch.                    |
| `git.tags`    | `list[str]` | List of tags that point to the current commit. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.apolo.us/index/apolo-flow-reference/workflow-syntax/batch-workflow-syntax/batch-contexts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
