rlmesh.Recorder

classfrom rlmesh import Recorder[source]

Accumulates recorded workloads and exports them as one bundle.

Recorder(
    *,
    result_set_id: str | None = None,
    fps: int = DEFAULT_FPS,
    quality: int = DEFAULT_QUALITY,
)

Each add() / capture() starts a new workload (one model x env x task cell). A single capture hooks object may drive several run calls; their episodes accumulate into that one workload, uniquely indexed.

Example – metrics only, path-agnostic::

rec = rlmesh.Recorder() result = rlmesh.run(model, env, episodes=50) rec.add(result, model=“smolvla”, env=“libero”, task=“libero-spatial-0”) rec.export(“results/run.zip”)

Example – with media, on the session path::

rec = rlmesh.Recorder() sess = rlmesh.session(model, env) sess.run( episodes=50, hooks=rec.capture(model=“smolvla”, env=“libero”, task=“libero-spatial-0”), ) rec.export(“results/run.zip”)

result_set_id

property[source]
property result_set_id: str

The locally minted id anchoring this bundle (re-upload dedupe key).

workloads

property[source]
property workloads: tuple[WorkloadRecord, ...]

The workloads recorded so far, in the order they were started.

add

function[source]
add(
    result: RunResult,
    *,
    model: str,
    env: str,
    task: str | None = None,
    config: dict[str, Any] | None = None,
    included_in_metrics: bool = True,
)

Record a completed RunResult as a new workload (no media).

The post-hoc path – works for any run’s return value, including pure rlmesh.run. For video/frames, use capture() instead.

capture

function[source]
capture(
    *,
    model: str,
    env: str,
    task: str | None = None,
    config: dict[str, Any] | None = None,
    cameras: list[str] | None = None,
    session: RunContext | None = None,
    video_info_keys: tuple[str, ...] = DEFAULT_VIDEO_INFO_KEYS,
    included_in_metrics: bool = True,
)

A RunHooks that records a live run into a new workload.

Frame sourcing:

  • By default the recorded sources are auto-discovered on the first step from the session running the hooks (received via on_run_start()): the env’s render() frame (when it exposes an rgb render mode) plus every declared image role, each to its own video – exactly the sources the live viewer offers, under the same labels.
  • cameras – explicit sources to record each step: env image roles (read as HWC) and/or "render" for the env’s render() frame. cameras=[] opts out of frames entirely (metrics only).
  • session – only needed when driving the hooks by hand (outside a run); an explicitly passed session also wins over the running loop’s RunContext. The render() frame is reachable on the session loop and, on the native Model.run loop, for a local env object; a vector env is refused unless cameras=[].

video_info_keys name the step-info keys checked for an env-produced video file path (the env renders its own video); the file is copied into the bundle. Recorded frames are encoded to AV1 mp4 in process.

to_dict

function[source]
to_dict(*, recorded_at: str | None = None)

The rlmesh.result.v1 document as a JSON-native dict.

export

function[source]
export(
    path: str | Path,
    *,
    archive: bool | str | None = None,
    recorded_at: str | None = None,
)

Write the bundle to path and return it.

Writes a folder by default, or a zip when path ends .zip or archive is True / "zip". archive=False forces a folder.

close

function[source]
close()

Remove the temp staging dir holding captured frame stacks. Idempotent.

Call after export(). Staged files are also under the OS temp dir, so a missed close is cleaned by the OS eventually.