nemo_gym.sandbox.providers.openshell.provider
nemo_gym.sandbox.providers.openshell.provider
OpenShell sandbox provider: sandboxes managed by an OpenShell gateway (github.com/NVIDIA/OpenShell).
The provider talks to the gateway’s gRPC control plane through the synchronous openshell
SDK; blocking SDK calls run on a thread pool bounded by exec.concurrency. The client and
thread pool are cached at module scope keyed on the connection config, so concurrent sandboxes
created from identical provider configs share one gRPC channel and one pool instead of
allocating one per sandbox. The SDK has no file-transfer API, so uploads stream bytes through
exec stdin (chunked to stay under the gateway’s gRPC message size limit) and downloads
round-trip through base64 on the sandbox’s stdout.
Module Contents
Classes
Functions
Data
API
Gateway connection settings. Defaults target a local plaintext gateway (deploy/docker compose).
Bases: SandboxCreateError
Raised when the OpenShell gateway cannot create a sandbox.
Bases: SandboxCreateVerificationError
Raised when a new sandbox fails its readiness probe.
Sandbox provider backed by an OpenShell gateway’s gRPC control plane.
Issue CreateSandbox, retrying transient gRPC failures with the same name.
Retrying with the same name is safe: if an earlier attempt actually committed, the retry fails ALREADY_EXISTS and the sandbox is recovered via GetSandbox.
Poll the readiness probe until it passes stable_count times or the deadline elapses.
Poll GetSandbox until NOT_FOUND (transient RPC failures keep polling until the deadline).
Poll GetSandbox until READY, raising on the ERROR/DELETING phases or the deadline.
Release the shared client/pool (closed for real when the last provider releases it).
Delete the sandbox (already-gone counts as success), then wait until it is fully gone.
Create a sandbox through the gateway, wait for the READY phase, then probe exec readiness.
spec.image is optional (the gateway’s configured default image is used when unset).
spec.ttl_s is not enforced (OpenShell sandboxes live until deleted) and only logs a
warning. spec.entrypoint is unsupported: the OpenShell supervisor owns the sandbox
entrypoint. spec.provider_options accepts providers (OpenShell credential-provider
names), policy (a SandboxPolicy mapping or YAML path), and template_resources /
driver_config (free-form driver passthrough Structs). A half-created sandbox is
deleted on any failure.
Download one sandbox file via a base64 round-trip (binary-safe over the text exec stream).
The whole file is buffered in memory (inflated 4/3 by base64), so this is intended for small-to-medium artifacts rather than large archives.
Run <shell> -c <command> through the gateway’s streaming exec; never raises for command failure.
The timeout is enforced by the gateway (timeout_seconds); the SDK extends its gRPC
deadline past it. user is ignored with a warning: the OpenShell exec API has no user
field, so commands run as the sandbox’s default user.
Sandbox phase via GetSandbox (missing -> STOPPED; RPC failure -> UNKNOWN).
Upload one local file by streaming its bytes through exec stdin (creates the parent dir).
Bytes are sent in exec.upload_chunk_bytes chunks because each chunk travels as a
single gRPC message that must stay under the gateway’s max decode size.
Validated per-sandbox options carried in SandboxSpec.provider_options.
One gRPC client + worker pool shared by every provider with the same connection config.
The grpc.StatusCode of an RPC error, else None.
Whether a CreateSandbox RPC failure is likely transient (safe to retry with the same name).
SandboxPhase -> SandboxStatus, built from the SDK’s generated proto constants.