> This page is for version 0.5.1.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.

# nemo_gym.utils.task_ids

The task ids a run selects (`task_ids` or `task_ids_fpath`), their digest, and the record a subset run keeps.

Nothing here writes; the run that collects the rows writes the record (`rollouts_task_selection.json`).

## Module Contents

### Classes

| Name                                                      | Description                                                                                    |
| --------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| [`TaskSelection`](#nemo_gym-utils-task_ids-TaskSelection) | The ids a run selects, as strings, and where they came from: `task_ids` or the id file's path. |

### Functions

| Name                                                                                | Description                                                                                                  |
| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| [`read_task_ids_file`](#nemo_gym-utils-task_ids-read_task_ids_file)                 | The ids a task id file lists, one per line; blank lines and lines starting with `#` are skipped.             |
| [`read_task_selection_record`](#nemo_gym-utils-task_ids-read_task_selection_record) | A saved selection record; None when the run selected no tasks (no record). An unreadable record is a subset  |
| [`task_ids_as_strings`](#nemo_gym-utils-task_ids-task_ids_as_strings)               | Inline ids as strings: Hydra reads an unquoted `7` as an int and `true` as a bool. A float is refused, since |
| [`task_ids_digest`](#nemo_gym-utils-task_ids-task_ids_digest)                       | The sha256 of the selected ids, sorted and unique, one per line: the same set always gives the same digest.  |
| [`task_selection`](#nemo_gym-utils-task_ids-task_selection)                         | The run's selection from its `task_ids` or `task_ids_fpath` setting; None when it selects no tasks by id.    |
| [`task_selection_record`](#nemo_gym-utils-task_ids-task_selection_record)           | What `rollouts_task_selection.json` holds: the source, the counts, the sorted ids and their digest.          |

### API

```python
class nemo_gym.utils.task_ids.TaskSelection()
```

**Bases:** `NamedTuple`

The ids a run selects, as strings, and where they came from: `task_ids` or the id file's path.

**`source`** `str`

---

**`task_ids`** `list[str]`

---

```python
nemo_gym.utils.task_ids.read_task_ids_file(
    fpath: str
) -> list[str]
```

The ids a task id file lists, one per line; blank lines and lines starting with `#` are skipped.

```python
nemo_gym.utils.task_ids.read_task_selection_record(
    path: pathlib.Path
) -> dict[str, typing.Any] | None
```

A saved selection record; None when the run selected no tasks (no record). An unreadable record is a subset
whose source and digest are unknown, never a run of every task.

```python
nemo_gym.utils.task_ids.task_ids_as_strings(
    value: typing.Any
) -> typing.Any
```

Inline ids as strings: Hydra reads an unquoted `7` as an int and `true` as a bool. A float is refused, since
its text (`1e3`, `1.50`) is gone; anything that is not a list is returned for the caller to reject.

```python
nemo_gym.utils.task_ids.task_ids_digest(
    task_ids: collections.abc.Sequence[str]
) -> str
```

The sha256 of the selected ids, sorted and unique, one per line: the same set always gives the same digest.

```python
nemo_gym.utils.task_ids.task_selection(
    task_ids: typing.Any,
    task_ids_fpath: str | None
) -> nemo_gym.utils.task_ids.TaskSelection | None
```

The run's selection from its `task_ids` or `task_ids_fpath` setting; None when it selects no tasks by id.

```python
nemo_gym.utils.task_ids.task_selection_record(
    selection: nemo_gym.utils.task_ids.TaskSelection,
    rows: int
) -> dict[str, typing.Any]
```

What `rollouts_task_selection.json` holds: the source, the counts, the sorted ids and their digest.