Skip to main content

enterprise_ai.sandbox

Source: sdks/python/src/enterprise_ai/sandbox/__init__.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Class SandboxClient​

/v1/sandbox/executions.

Resource

SandboxClient.execute​

execute(image: str, command: list[str] | None = None, profile: str = 'gvisor', limits: dict[str, Any] | None = None, env: dict[str, str] | None = None, run_id: str | None = None, **extra: Any) -> Any

Run a command in a sandbox. Creates a sandbox execution: the image and command run as a Kubernetes Job with the runtime class of the profile (gVisor, Kata, Wasm) when Kubernetes is configured (status: submitted, or failed if the submission fails). Needs tenant_admin, developer or agent; the profile none needs tenant_admin (403). Invalid profile, image or limits answer 422 invalid_sandbox. The usage is metered and the request audited as sandbox.execute.

Route: /v1/sandbox/executions (POST).

NameTypeDefaultRequiredDescription
imagestryesContainer image reference (1 to 500 characters, lowercase registry path, tag or digest allowed).
commandlist[str] | NoneNonenoCommand and arguments, one item per argument.
profilestr'gvisor'noIsolation profile: gvisor (default), kata, wasm or none (no isolation, tenant_admin only).
limitsdict[str, Any] | NoneNonenoResource limits: cpu (default 500m, at most 4 cores), memory (default 512Mi, at most 8Gi), timeout_seconds (1 to 3600, default 300), gpu (at most 1), max_steps.
envdict[str, str] | NoneNonenoEnvironment variables, string values.
run_idstr | NoneNonenoRun the execution belongs to (must exist); used for metering.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Run a command in a sandbox".

Raises: ValueError, the typed errors of the transport (Errors).

SandboxClient.get​

get(execution_id: str) -> Any

Get a sandbox execution. Returns the sandbox execution: profile, image, command, limits, generated Kubernetes Job spec, status, executor and result. 404 sandbox_execution_not_found.

Route: /v1/sandbox/executions/{execution_id} (GET).

NameTypeDefaultRequiredDescription
execution_idstryesIdentifier (UUID) of the sandbox execution.

Returns: Any. Decoded JSON answer of the operation "Get a sandbox execution".

Raises: the typed errors of the transport (Errors).

SandboxClient.wait​

wait(execution_id: str, timeout: float = 300.0, interval: float = 1.0) -> dict[str, Any]

Poll until the execution finishes (sync client only).

NameTypeDefaultRequiredDescription
execution_idstryesIdentifier of the sandbox execution.
timeoutfloat300.0noMaximum wait in seconds (default 300); the last read is then returned without error.
intervalfloat1.0noSeconds between two reads (default 1).

Returns: dict[str, Any]. The execution, final when its status is succeeded, failed, timeout, killed or cancelled.

Raises: TypeError.

SandboxClient.wait_async​

async wait_async(execution_id: str, timeout: float = 300.0, interval: float = 1.0) -> dict[str, Any]

Async poll until the execution finishes.

NameTypeDefaultRequiredDescription
execution_idstryesIdentifier of the sandbox execution.
timeoutfloat300.0noMaximum wait in seconds (default 300); the last read is then returned without error.
intervalfloat1.0noSeconds between two reads (default 1).

Returns: dict[str, Any]. The execution, final when its status is succeeded, failed, timeout, killed or cancelled.