Remote Environments¶
Remote clients connect to an environment endpoint and expose the same core calls as a local
Gymnasium environment: reset, step, render, and close.
Use the concrete backend modules in application code:
rlmesh.RemoteEnvandrlmesh.RemoteVectorEnvpreserve RLMesh-native values.rlmesh.numpy.RemoteEnvandrlmesh.numpy.RemoteVectorEnvdecode tensor leaves as NumPy arrays.rlmesh.torch.RemoteEnvandrlmesh.torch.RemoteVectorEnvdecode tensor leaves as Torch tensors.
Every remote client keeps the endpoint handshake in env_contract. The spec property is an alias
for that same contract. observation_space and action_space are client-side wrappers built from
the contract’s SpaceSpec values.
Render Viewer¶
Every remote client (and the experimental sandbox sessions) inherits two viewer methods from a shared mixin:
open_viewer(*, env_index=0, fps="env")opens a local render window and streams frames after eachreset,step, andrender.env_indexselects which sub-environment of a vector client to view.fpsaccepts"env"(readrender_fpsfrom environment metadata), a positive number for an explicit limit, orNoneto disable pacing.close_viewer()closes the window if one is open. It is also called on clientclose().
The viewer is best-effort and experimental. It launches a separate GUI process via
python -m rlmesh viewer, so it needs a desktop host. The environment must produce frames,
typically render_mode="rgb_array". Frame pushes are dropped instead of blocking the step loop when
the viewer stalls.
Single Environment Base¶
- class rlmesh._client.RemoteEnvBase[source]¶
Bases:
ViewerMixin,Generic[ValueT,ActionT]Base class for backend-specific single-environment remote clients.
Backend modules such as
rlmesh.numpyandrlmesh.torchconfigure the value bridge. User code should normally instantiate those concrete backends instead of this base class.- Parameters:
address – Endpoint address such as
"tcp://127.0.0.1:5555".host – TCP host helper used when
addressis omitted.port – TCP port helper used when
addressis omitted.path – Unix socket path helper used when
addressis omitted.transport – Explicit transport selector.
- __init__(address=None, *, host=None, port=None, path=None, transport=None)[source]¶
- Parameters:
address (str | None)
host (str | None)
port (int | None)
path (str | None)
transport (Literal['tcp', 'unix'] | None)
- Return type:
None
- property env_contract: EnvContract[source]¶
Environment contract returned by the endpoint handshake.
- property observation_space: Space[ValueT][source]¶
Observation space loaded from the remote environment contract.
- property action_space: Space[ActionT][source]¶
Action space loaded from the remote environment contract.
- property metadata: Mapping[str, object][source]¶
Endpoint metadata reported by the environment contract.
- property observation_space_spec: SpaceSpec[source]¶
Native observation space spec reported by the endpoint.
- reset(*, seed=None, options=None)[source]¶
Reset the remote environment and decode the observation.
- Parameters:
seed (int | None) – Optional environment reset seed.
options (dict[str, object] | None) – Optional reset options forwarded to the environment.
- Returns:
A decoded observation and reset info dictionary.
- Return type:
tuple[ValueT, ResetInfo]
- step(action)[source]¶
Step the remote environment with one encoded action.
- Parameters:
action (ActionT) – Action accepted by the remote environment action space.
- Returns:
Observation, reward, terminated flag, truncated flag, and step info.
- Return type:
tuple[ValueT, float, bool, bool, StepInfo]
Vector Environment Base¶
- class rlmesh._client.RemoteVectorEnvBase[source]¶
Bases:
ViewerMixin,Generic[ValueT,ActionT]Base class for backend-specific vector-environment remote clients.
Backend modules such as
rlmesh.numpyandrlmesh.torchconfigure the value bridge. User code should normally instantiate those concrete backends instead of this base class.- Parameters:
address – Endpoint address such as
"tcp://127.0.0.1:5555".host – TCP host helper used when
addressis omitted.port – TCP port helper used when
addressis omitted.path – Unix socket path helper used when
addressis omitted.transport – Explicit transport selector.
- __init__(address=None, *, host=None, port=None, path=None, transport=None)[source]¶
- Parameters:
address (str | None)
host (str | None)
port (int | None)
path (str | None)
transport (Literal['tcp', 'unix'] | None)
- Return type:
None
- property env_contract: EnvContract[source]¶
Environment contract returned by the endpoint handshake.
- property single_observation_space: Space[ValueT][source]¶
Observation space for one environment in the vector.
- property single_action_space: Space[ActionT][source]¶
Action space for one environment in the vector.
- property metadata: Mapping[str, object][source]¶
Endpoint metadata reported by the environment contract.
The wire codec degrades Gymnasium’s
AutoresetModeenum to its plain string value, but Gymnasium 1.x vector consumers (for exampleRecordEpisodeStatistics) assert thatmetadata["autoreset_mode"]is anAutoresetModeinstance. We restore the enum here so a Gymnasium-compliant training loop can read the server-side autoreset convention.
- property observation_space_spec: SpaceSpec[source]¶
Native observation space spec reported by the endpoint.
- reset(*, seed=None, options=None)[source]¶
Reset all remote environments and decode the observations.
- Parameters:
seed (int | list[int] | None) – Optional seed or per-environment seed list.
options (dict[str, object] | None) – Optional reset options forwarded to the vector environment.
- Returns:
Batched decoded observations and reset info dictionary.
- Return type:
tuple[ValueT, ResetInfo]
- step(actions)[source]¶
Step all remote environments with a batch of actions.
- Parameters:
actions (ActionT) – Batched actions accepted by the vector endpoint.
- Returns:
Batched observations, rewards, terminations, truncations, and info.
- Return type:
tuple[ValueT, ValueT, ValueT, ValueT, StepInfo]