This reference describes unreleased code on main; no release documents it yet.

rlmesh::Session

structPreviewuse rlmesh::Session;[source]

A model bound to one env. Drive it with reset / predict / step, or pump whole episodes with run. It borrows the model and the env for 'a; close releases what it made, and Drop acts as close on an error (no viewer hold, errors swallowed).

struct Session<'a>

Methods

reset

method[source]
fn reset(
    &mut self,
    seed: Option<i64>,
    trial_index: Option<i64>,
) -> Result<(Value, InfoDict)>

Begin an episode: end the open one (the model’s on_episode_end), then reset the env. trial_index reaches only an env that declares the option; another resets without it and warns.

reset_async

method[source]
async fn reset_async(
    &mut self,
    seed: Option<i64>,
    trial_index: Option<i64>,
) -> Result<(Value, InfoDict)>

The async twin of reset.

predict

method[source]
fn predict(&mut self, observation: Value) -> Result<Value>

Map one observation to an env-ready action (the model’s adapter applied, a chunk replayed one action per step).

predict_async

method[source]
async fn predict_async(&mut self, observation: Value) -> Result<Value>

The async twin of predict.

step

method[source]
fn step(
    &mut self,
    action: Value,
) -> Result<(Value, f64, bool, bool, InfoDict)>

Apply one action to the env ((observation, reward, terminated, truncated, info)).

step_async

method[source]
async fn step_async(
    &mut self,
    action: Value,
) -> Result<(Value, f64, bool, bool, InfoDict)>

The async twin of step.

run

method[source]
fn run(&mut self, options: SessionRunOptions<'_>) -> Result<RunResult>

Drive whole episodes and return their result; the session stays open. Hook errors abort the run, and on_run_end fires exactly once.

run_async

method[source]
async fn run_async(
    &mut self,
    options: SessionRunOptions<'_>,
) -> Result<RunResult>

The async twin of run. Its hooks run inside this future.

done

method[source]
fn done(&self) -> bool

Whether the current episode has terminated or truncated.

contract

method[source]
fn contract(&mut self) -> Result<&EnvContract>

The connected env’s contract (connects on first use).

contract_async

method[source]
async fn contract_async(&mut self) -> Result<&EnvContract>

The async twin of contract.

num_envs

method[source]
fn num_envs(&mut self) -> Result<u64>

Lanes the connected env runs (a session drives one).

num_envs_async

method[source]
async fn num_envs_async(&mut self) -> Result<u64>

The async twin of num_envs.

selected_workflow_edition

method[source]
fn selected_workflow_edition(&mut self) -> Result<String>

The workflow edition the session’s env connection settled on; a local env negotiates none (the RuntimeError class).

selected_workflow_edition_async

method[source]
async fn selected_workflow_edition_async(&mut self) -> Result<String>

The async twin of selected_workflow_edition.

reader

method[source]
fn reader(&mut self, items: &[ReadItem]) -> Result<Reader>

Resolve a reusable reader for semantic roles or single-role input leaves.

reader_async

method[source]
async fn reader_async(&mut self, items: &[ReadItem]) -> Result<Reader>

The async twin of reader.

read

method[source]
fn read(
    &mut self,
    observation: &Value,
    item: impl Into<ReadItem>,
) -> Result<Value>

Read a role or leaf from an observation.

read_async

method[source]
async fn read_async(
    &mut self,
    observation: &Value,
    item: impl Into<ReadItem>,
) -> Result<Value>

The async twin of read.

observation_roles

method[source]
fn observation_roles(&mut self) -> Result<ObservationRoles>

Observation roles grouped by modality in authored declaration order.

observation_roles_async

method[source]
async fn observation_roles_async(&mut self) -> Result<ObservationRoles>

The async twin of observation_roles.

frame_sources

method[source]
fn frame_sources(&mut self) -> Result<FrameSources<'_>>

Discover sources, borrowing this session for its render callable.

frame_sources_async

method[source]
async fn frame_sources_async(&mut self) -> Result<FrameSources<'_>>

The async twin of frame_sources.

run_context

method[source]
fn run_context(&mut self) -> Result<Arc<dyn RunContext>>

This session as its hooks see it (connects first). The context fails with the RuntimeError class once the session has closed.

run_context_async

method[source]
async fn run_context_async(&mut self) -> Result<Arc<dyn RunContext>>

The async twin of run_context.

cancel_handle

method[source]
fn cancel_handle(&self) -> CancelToken

The session’s cancel token: the SessionOptions::cancel one, or one the session made; the same token on every call.

close

method[source]
fn close(&mut self) -> Result<()>

Close the session: end an open episode (the model’s on_episode_end), release the route and a connection the session dialed, and on close_env shut the env down. Idempotent; the first release error is returned. The model is never closed.

close_async

method[source]
async fn close_async(&mut self) -> Result<()>

The async twin of close.

Trait implementations

  • impl Debug for Session<'_>
  • impl Drop for Session<'_>