> This page is for version Main (default).
> 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.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.orchestration.executors.git_ref

## Module Contents

### Classes

| Name                                                                                 | Description                                                                                     |
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| [`_NetworkCheckError`](#nemo_gym-orchestration-executors-git_ref-_NetworkCheckError) | The repo could not be listed: a network, access or remote failure, not an answer about the ref. |

### Functions

| Name                                                                                             | Description                                                                                         |
| ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| [`_git`](#nemo_gym-orchestration-executors-git_ref-_git)                                         | -                                                                                                   |
| [`_pushed_in_local_clone`](#nemo_gym-orchestration-executors-git_ref-_pushed_in_local_clone)     | Whether a remote-tracking ref of `repo` in this Gym's own clone contains commit `sha` right after a |
| [`_ref_exists`](#nemo_gym-orchestration-executors-git_ref-_ref_exists)                           | -                                                                                                   |
| [`_repo_key`](#nemo_gym-orchestration-executors-git_ref-_repo_key)                               | `url` without scheme, user, `.git` and case, so an https and an ssh URL of one repo compare equal.  |
| [`validate_gym_install_ref`](#nemo_gym-orchestration-executors-git_ref-validate_gym_install_ref) | Fail the submit early when `driver.gym_install.ref` cannot be found in `repo`.                      |

### Data

[`NEMO_GYM_SUBMIT_NO_REF_CHECK_ENV_VAR_NAME`](#nemo_gym-orchestration-executors-git_ref-NEMO_GYM_SUBMIT_NO_REF_CHECK_ENV_VAR_NAME)

[`_FULL_SHA`](#nemo_gym-orchestration-executors-git_ref-_FULL_SHA)

[`_GIT_ENV`](#nemo_gym-orchestration-executors-git_ref-_GIT_ENV)

[`_GIT_TIMEOUT_SECONDS`](#nemo_gym-orchestration-executors-git_ref-_GIT_TIMEOUT_SECONDS)

[`_GYM_CHECKOUT`](#nemo_gym-orchestration-executors-git_ref-_GYM_CHECKOUT)

[`_HEX`](#nemo_gym-orchestration-executors-git_ref-_HEX)

[`_RETRY_WAITS_SECONDS`](#nemo_gym-orchestration-executors-git_ref-_RETRY_WAITS_SECONDS)

[`logger`](#nemo_gym-orchestration-executors-git_ref-logger)

### API

```python
class nemo_gym.orchestration.executors.git_ref._NetworkCheckError()
```

Exception

**Bases:** `Exception`

The repo could not be listed: a network, access or remote failure, not an answer about the ref.

```python
nemo_gym.orchestration.executors.git_ref._git(
    args: str = (),
    cwd: str | None = None
) -> subprocess.CompletedProcess
```

```python
nemo_gym.orchestration.executors.git_ref._pushed_in_local_clone(
    repo: str,
    sha: str
) -> bool
```

Whether a remote-tracking ref of `repo` in this Gym's own clone contains commit `sha` right after a
successful `git fetch --prune` of that remote: then `repo` serves it.

Only remote-tracking refs count, so a local commit that was never pushed does not. A remote whose fetch fails is
not consulted, so a stale ref (a branch deleted since the last fetch) never vouches for a commit. Any failure here
(no clone, no such remote, git missing) answers False.

```python
nemo_gym.orchestration.executors.git_ref._ref_exists(
    repo: str,
    ref: str
) -> bool
```

```python
nemo_gym.orchestration.executors.git_ref._repo_key(
    url: str
) -> str
```

`url` without scheme, user, `.git` and case, so an https and an ssh URL of one repo compare equal.

```python
nemo_gym.orchestration.executors.git_ref.validate_gym_install_ref(
    config: nemo_gym.orchestration.api.SubmitConfig
) -> None
```

Fail the submit early when `driver.gym_install.ref` cannot be found in `repo`.

A branch or tag is looked up with one `git ls-remote`, which transfers only ref names, and a
full commit hash that is not a branch/tag tip is probed with a depth-1, blob-less fetch. A
failure to reach the repo (timeout, unreachable or nonexistent repo, auth) is retried after each
of `_RETRY_WAITS_SECONDS`; when every attempt fails, the submit fails with an error that names a
network check, not a missing ref. A missing git binary is not retried.

The repo always answers when it can be reached; a ref it does not have fails the submit. Only when
every attempt failed to reach it is a full commit hash checked in this Gym's own clone of `repo`,
and only after a `git fetch --prune` of that remote succeeds, so a remote branch deleted since the
clone's last fetch cannot vouch for it; a hash such a fresh remote-tracking ref contains is accepted
with a warning that the local fallback was used. Set NEMO_GYM_SUBMIT_NO_REF_CHECK=true to skip the
check.

```python
nemo_gym.orchestration.executors.git_ref.NEMO_GYM_SUBMIT_NO_REF_CHECK_ENV_VAR_NAME = 'NEMO_GYM_SUBMIT_NO_REF_CHECK'
```

```python
nemo_gym.orchestration.executors.git_ref._FULL_SHA = re.compile('[0-9a-f]{40}')
```

```python
nemo_gym.orchestration.executors.git_ref._GIT_ENV = {None: os.environ, 'GIT_TERMINAL_PROMPT': '0', 'GIT_ASKPASS': 'true'}
```

```python
nemo_gym.orchestration.executors.git_ref._GIT_TIMEOUT_SECONDS = 10
```

```python
nemo_gym.orchestration.executors.git_ref._GYM_CHECKOUT = Path(__file__).resolve().parents[3]
```

```python
nemo_gym.orchestration.executors.git_ref._HEX = re.compile('[0-9a-f]{4,40}')
```

```python
nemo_gym.orchestration.executors.git_ref._RETRY_WAITS_SECONDS = (10, 30, 60)
```

```python
nemo_gym.orchestration.executors.git_ref.logger = logging.getLogger(__name__)
```