These docs describe unreleased changes on main. See the latest release.

rlmesh.torch.SandboxVectorEnv

classExperimentalfrom rlmesh.torch import SandboxVectorEnv[source]

Experimental Torch-backed owned sandbox session for vectorized environments.

SandboxVectorEnv(
    source: str,
    /,
    num_envs: int,
    *,
    vectorization_mode: str | None = None,
    build: SandboxBuild | None = None,
    runtime: SandboxRuntime | None = None,
    connect_timeout_seconds: float = SANDBOX_REMOTE_CONNECT_TIMEOUT_SECONDS,
    **params: object,
) -> None

The sandbox starts multiple isolated environment instances and exposes them through the same vector client interface as a separately served endpoint.

Parameters

NameTypeDescription
sourcestrA gym id / gym:// / hf:// source built from source, or a prebuilt rlmesh-serving image (docker://img / bare img:tag).
num_envsintNumber of environment instances to create.
vectorization_modestr | NoneVectorization mode requested inside the sandbox.
buildSandboxBuild | NoneOptional SandboxBuild -- build-from-source infrastructure; ignored for a prebuilt image.
runtimeSandboxRuntime | NoneOptional SandboxRuntime -- docker run settings (gpus / devices / volumes); prebuilt-image source only.
**paramsobjectEnvironment construction params -- the binding forwarded to the factory's make (validated in the container before construction).

Examples

>>> from rlmesh.torch import SandboxVectorEnv
>>> envs = SandboxVectorEnv("CartPole-v1", num_envs=2)
>>> observations, infos = envs.reset(seed=42)
>>> envs.close()

sandbox

attribute[source]
sandbox

source

property[source]
property source: str

Original sandbox source string requested by the caller.

close

function[source]
close() -> None

Detach the remote client and stop the owned sandbox container.

num_envs

property[source]
property num_envs: int

Number of environment instances served by the endpoint.

single_observation_space

property[source]
property single_observation_space: Space[ValueT]

Observation space for one environment in the vector.

single_action_space

property[source]
property single_action_space: Space[ActionT]

Action space for one environment in the vector.

observation_space

property[source]
property observation_space: Space[ValueT]

Alias for single_observation_space.

action_space

property[source]
property action_space: Space[ActionT]

Alias for single_action_space.

reset

function[source]
reset(
    *,
    seed: int | list[int] | None = None,
    options: dict[str, object] | None = None,
) -> tuple[ValueT, ResetInfo]

Reset all remote environments and decode the observations.

Parameters

NameTypeDescription
seedint | list[int] | NoneOptional seed or per-environment seed list.
optionsdict[str, object] | NoneOptional reset options forwarded to the vector environment.

Returns

TypeDescription
ValueTBatched decoded observations and reset info dictionary. Besides the
ResetInfoenv's own keys, the info carries the runtime-reserved
tuple[ValueT, ResetInfo]episode_ids (the runtime-minted episode id per lane). An env key
tuple[ValueT, ResetInfo]of the same name wins and shadows it; the client logs that once.

step

function[source]
step(
    actions: ActionT,
) -> tuple[ValueT, ValueT, ValueT, ValueT, StepInfo]

Step all remote environments with a batch of actions.

Parameters

NameTypeDescription
actionsActionTBatched actions accepted by the vector endpoint.

Returns

TypeDescription
ValueTBatched observations, rewards, terminations, truncations, and info.
ValueTBesides the env's own keys, the info carries two runtime-reserved
ValueTkeys on every step: episode_ids (the runtime-minted episode id
ValueTper lane) and completed_episodes (how many lanes' episodes
StepInfoended on this step, 0 when none did). An env key of the same
tuple[ValueT, ValueT, ValueT, ValueT, StepInfo]name wins and shadows the runtime's; the client logs that once.

address

property[source]
property address: str

Endpoint address this client is connected to.

env_id

property[source]
property env_id: str

This connection’s container id (UUIDv7).

A stable correlation identity, distinct from the human env name (env_contract.id).

selected_workflow_edition

property[source]
property selected_workflow_edition: str

The workflow edition this connection negotiated with the env.

The highest edition both sides can drive, at or below whatever either declared, in the exact spelling they agreed on – so a prerelease build reports its cohort, not the bare sealed base. Named apart from the workflow_edition declaration surfaces on purpose: this is what was agreed, not what this side asked for.

env_contract

property[source]
property env_contract: EnvContract

Environment contract returned by the endpoint handshake.

render_mode

property[source]
property render_mode: str | None

Configured render mode reported by the endpoint.

metadata

property[source]
property metadata: Metadata

Endpoint metadata reported by the environment contract.

observation_space_spec

property[source]
property observation_space_spec: SpaceSpec

Native observation space spec reported by the endpoint.

action_space_spec

property[source]
property action_space_spec: SpaceSpec

Native action space spec reported by the endpoint.

render

function[source]
render(*, env_index: int = 0) -> ValueT | None

Render a frame from the remote environment.

Parameters

NameTypeDescription
env_indexintEnvironment index to render. Single environments use 0.

Returns

TypeDescription
ValueT | NoneA decoded render frame, or None when the environment has no frame.

shutdown

function[source]
shutdown(reason: str = 'owner shutdown') -> bool

Request owner-level shutdown of the remote environment endpoint.