Datasets:
Formats:
csv
Languages:
English
Size:
< 1K
Tags:
robotics
embodied-ai
human-demonstration
egocentric-video
bimanual-manipulation
tactile-sensing
License:
File size: 1,860 Bytes
9ff4bea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | """Helper functions for directly working with recordings."""
from __future__ import annotations
from typing import TYPE_CHECKING
from rerun import bindings
if TYPE_CHECKING:
from .recording_stream import RecordingStream
def memory_recording(recording: RecordingStream | None = None) -> MemoryRecording:
"""
Streams all log-data to a memory buffer.
This can be used to display the RRD to alternative formats such as html.
See: [rerun.notebook_show][].
Parameters
----------
recording:
Specifies the [`rerun.RecordingStream`][] to use.
If left unspecified, defaults to the current active data recording, if there is one.
See also: [`rerun.init`][], [`rerun.set_global_data_recording`][].
Returns
-------
MemoryRecording
A memory recording object that can be used to read the data.
"""
inner = bindings.memory_recording(
recording=recording.to_native() if recording is not None else None,
)
if inner is None:
raise RuntimeError("No recording was provided or set as current.")
return MemoryRecording(inner)
class MemoryRecording:
"""A recording that stores data in memory."""
def __init__(self, storage: bindings.PyMemorySinkStorage) -> None:
self.storage = storage
def num_msgs(self) -> int:
"""
The number of pending messages in the MemoryRecording.
Note: counting the messages will flush the batcher in order to get a deterministic count.
"""
return self.storage.num_msgs() # type: ignore[no-any-return]
def drain_as_bytes(self) -> bytes:
"""
Drains the MemoryRecording and returns the data as bytes.
This will flush the current sink before returning.
"""
return self.storage.drain_as_bytes() # type: ignore[no-any-return]
|