Contracts and Specs¶
Contracts and specs describe what a remote endpoint serves.
EnvContract¶
- class rlmesh.specs.EnvContract¶
Immutable description of an environment endpoint.
EnvContract is returned by:
EnvServer.env_contractEnvServer.specRemoteEnv.env_contractRemoteEnv.specRemoteVectorEnv.env_contractRemoteVectorEnv.specsandbox session
env_contractandspecproperties
The server builds the contract when it wraps the Python environment. For Gymnasium environments,
id comes from env.spec.id when available and falls back to "UnknownEnv-v1". Spaces are parsed
from observation_space and action_space for single environments, or from
single_observation_space and single_action_space for vector environments.
Attribute |
Type |
Meaning |
|---|---|---|
|
|
Environment id reported by the wrapped environment. |
|
|
Alias returning the same contract shape. |
|
|
Alias returning the same contract shape. |
|
|
Configured render mode, or |
|
|
Number of environment instances served by the endpoint. |
|
|
Optional environment metadata. |
|
|
Native spec for one observation. |
|
|
Native spec for one action. |
to_dict() returns a serializable dictionary containing the same fields, with nested space specs
converted to dictionaries.
SpaceSpec¶
- class rlmesh.specs.SpaceSpec¶
Immutable native description of a space.
SpaceSpec is the wire-safe description of a space. A Space wrapper is the Python object that can
sample, seed, and validate values from that spec.
Attribute or method |
Type |
Meaning |
|---|---|---|
|
|
Space family such as |
|
|
Tensor-like shape for spaces where shape is meaningful. |
|
|
Element dtype reported by the native space spec. |
|
|
Native detail payload for kind-specific fields. |
|
|
Dictionary form used by higher-level wrappers. |
|
|
Native sampler and validator for the spec. |
|
|
Best-effort conversion to a Gymnasium space. |
Use rlmesh.spaces.space_from_spec(spec) for a Python wrapper around a SpaceSpec. Use
rlmesh.spaces.to_gymnasium_space(spec) when code expects a Gymnasium space object.
ServeOptions¶
- class rlmesh.ServeOptions¶
Native options controlling endpoint lifecycle behavior.
Constructor argument |
Type |
Meaning |
|---|---|---|
|
|
Whether clients may request endpoint shutdown. |
|
|
Optional idle timeout before the server exits. |
|
|
Optional grace period for in-flight work during shutdown. |
|
|
Optional timeout for closing the wrapped environment. |
Pass options to EnvServer(..., options=options) or model-serving APIs that accept serve options.
Tensor¶
- class rlmesh.Tensor¶
Native tensor value used at the dependency-free RLMesh value boundary.
Tensor is a validated transport container: immutable element bytes plus shape, dtype, and stride
metadata, with DLPack and buffer-protocol edges. It is not an ndarray. Compute, slicing, and
broadcasting belong to the frameworks. The NumPy, Torch, and JAX backends convert tensor leaves to
backend arrays or tensors.
Attribute or method |
Type |
Meaning |
|---|---|---|
|
|
Tensor dimensions. |
|
|
Element dtype name (for example |
|
|
Number of dimensions. |
|
|
Number of elements. |
|
|
Element data size in bytes. |
|
|
Byte strides per dimension, C order. |
|
|
Device holding the data; currently always |
|
|
Whether elements are laid out C-contiguously. |
|
|
Same elements, new shape; zero-copy view when contiguous. |
|
|
Deep copy backed by fresh storage. |
|
|
Read-only N-D typed memory view over the elements. |
|
|
Copy the element bytes (C order) into Python bytes. |
|
capsule |
DLPack export; negotiates legacy or v1.0 capsules. |
|
|
DLPack device tuple, |
|
|
Static method; imports (and copies) from any DLPack producer. |
Use rlmesh.numpy.asarray(tensor) to get a writable NumPy copy of an RLMesh tensor
(numpy.from_dlpack(tensor) for a zero-copy, read-only view), rlmesh.torch.as_tensor(tensor) to
view or copy it as a Torch tensor, and rlmesh.jax.asarray(tensor) to import it as a JAX array.
bfloat16 tensors are not representable through the buffer protocol; use DLPack or tobytes() for
those.