nemo_gym.sandbox.providers.openshell
nemo_gym.sandbox.providers.openshell
OpenShell sandbox provider package.
Submodules
Package Contents
Classes
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.
Run CreateSandbox on a worker. Cancelling the await does not stop a call already running, so a create that commits after the cancel is deleted when it returns.
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.
Delete this process’s orphaned sandboxes: ones it no longer tracks, for example a create cancelled after the gateway committed it. Selected by the process label, which needs attribution to be enabled.
Run the SDK exec and time it inside the worker thread, so executor queueing is not counted.
Poll the readiness probe until it passes stable_count times or the deadline elapses.
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).
Does not wait for deletes: they run on their own workers. When no sandbox of this process is still
live or being created, it first deletes this process’s orphaned sandboxes (see _reap_orphans).
Hand the sandbox’s delete to a worker thread and return without waiting for the gateway.
The worker deletes, waits until the sandbox is gone when operations.close_wait_deleted is set, and
retries transient failures. It is already queued when this returns and runs to completion at interpreter
exit even if the event loop is gone. Every outcome is logged with the sandbox name; a delete that fails
for good is logged as possibly leaked and then forgotten.
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.