nemo_gym.sandbox.utils
nemo_gym.sandbox.utils
Sandbox utility helpers.
Module Contents
Functions
Data
API
Remove partial uploads after a failure, so a borrowed sandbox does not keep them.
CPU_CAP_ENV_VARS derived from a sandbox CPU limit; empty when unset.
Download a file’s bytes unchanged through file transfer.
Return the sandbox path stage_media writes file to, which depends only on its content and type.
Download UTF-8 text, replacing invalid bytes in partial process output.
Line endings become \n, as when reading a file in text mode.
Apply ordered image-prefix rewrites used by sandbox configs.
Write each media file to its media_path and return the paths, in order.
Harness CLIs read media from files, so an agent decodes prompt media with nemo_gym.core.split_text_and_media,
stages it here and passes the paths to the harness.
The sandbox’s default user creates the media directory, so it can rename files there even when uploads run as
another user. Each file is uploaded under a unique name, readable by every user, and then renamed onto its path in
the same directory. The rename is atomic, so a session sharing the sandbox never reads a partly written file, and
replacing an existing file swaps in identical bytes. When staging fails, the partial uploads are removed.
Raises:
SandboxUnavailableError: The provider could not run a staging command, for example because it timed out.SandboxTransferError: A staging command failed inside the sandbox, for example on a permission error.
Upload bytes unchanged through file transfer without shell interpolation.
Upload UTF-8 text through file transfer without shell interpolation.