Skip to navigation

nemo_gym.sandbox.providers.utils

View as MarkdownOpen in Claude

Helpers shared by the built-in sandbox providers.

These were previously duplicated verbatim across the enroot, apptainer, and opensandbox providers. They live here so there is a single implementation.

Module Contents

Functions

NameDescription
coerce_configAccept either a config dataclass instance or a plain mapping (Hydra YAML).
kill_cancelled_commandKill the process group of a CLI command whose wait was cancelled, then reap it.
path_under_mountIf path is inside the mount, return its path relative to the mount; else None.

Data

REAP_TIMEOUT_S

API

nemo_gym.sandbox.providers.utils.coerce_config(
value: typing.Any,
config_cls: type[typing.Any]
) -> typing.Any

Accept either a config dataclass instance or a plain mapping (Hydra YAML).

nemo_gym.sandbox.providers.utils.kill_cancelled_command(
proc: asyncio.subprocess.Process
) -> None
async

Kill the process group of a CLI command whose wait was cancelled, then reap it.

A provider runner calls this when the await on its command is cancelled, for example by the time limit of AsyncSandbox.stop, and then re-raises the cancellation. Without it, only the runner’s own command timeout kills the process, so a cancelled call leaves the command running. The reap is shielded from the cancellation that is still in force and bounded by REAP_TIMEOUT_S.

nemo_gym.sandbox.providers.utils.path_under_mount(
mount_point: str,
path: str
) -> str | None

If path is inside the mount, return its path relative to the mount; else None.

nemo_gym.sandbox.providers.utils.REAP_TIMEOUT_S = 5.0