Skip to navigation

nemo_gym.orchestration.executors.git_ref

View as Markdown

Module Contents

Classes

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

Functions

NameDescription
_git-
_pushed_in_local_cloneWhether a remote-tracking ref of repo in this Gym’s own clone contains commit sha right after a
_ref_exists-
_repo_keyurl without scheme, user, .git and case, so an https and an ssh URL of one repo compare equal.
validate_gym_install_refFail the submit early when driver.gym_install.ref cannot be found in repo.

Data

NEMO_GYM_SUBMIT_NO_REF_CHECK_ENV_VAR_NAME

_FULL_SHA

_GIT_ENV

_GIT_TIMEOUT_SECONDS

_GYM_CHECKOUT

_HEX

_RETRY_WAITS_SECONDS

logger

API

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.

nemo_gym.orchestration.executors.git_ref._git(
args: str = (),
cwd: str | None = None
) -> subprocess.CompletedProcess
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.

nemo_gym.orchestration.executors.git_ref._ref_exists(
repo: str,
ref: str
) -> bool
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.

nemo_gym.orchestration.executors.git_ref.validate_gym_install_ref(
) -> 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.

nemo_gym.orchestration.executors.git_ref.NEMO_GYM_SUBMIT_NO_REF_CHECK_ENV_VAR_NAME = 'NEMO_GYM_SUBMIT_NO_REF_CHECK'
nemo_gym.orchestration.executors.git_ref._FULL_SHA = re.compile('[0-9a-f]{40}')
nemo_gym.orchestration.executors.git_ref._GIT_ENV = {None: os.environ, 'GIT_TERMINAL_PROMPT': '0', 'GIT_ASKPASS': 'true'}
nemo_gym.orchestration.executors.git_ref._GIT_TIMEOUT_SECONDS = 10
nemo_gym.orchestration.executors.git_ref._GYM_CHECKOUT = Path(__file__).resolve().parents[3]
nemo_gym.orchestration.executors.git_ref._HEX = re.compile('[0-9a-f]{4,40}')
nemo_gym.orchestration.executors.git_ref._RETRY_WAITS_SECONDS = (10, 30, 60)
nemo_gym.orchestration.executors.git_ref.logger = logging.getLogger(__name__)