recording_stream.py
rerun.recording_stream
class RecordingStream(inner)
A RecordingStream is used to send data to Rerun.
You can instantiate a RecordingStream by calling either rerun.init
(to create a global
recording) or rerun.new_recording
(for more advanced use cases).
Multithreading
A RecordingStream can safely be copied and sent to other threads.
You can also set a recording as the global active one for all threads (rerun.set_global_data_recording
)
or just for the current thread (rerun.set_thread_local_data_recording
).
Similarly, the with
keyword can be used to temporarily set the active recording for the
current thread, e.g.:
with rec:
rr.log_points(...)
See also: rerun.get_data_recording
, rerun.get_global_data_recording
,
rerun.get_thread_local_data_recording
.
Available methods
Every function in the Rerun SDK that takes an optional RecordingStream as a parameter can also be called as a method on RecordingStream itself.
This includes, but isn't limited to:
- Metadata-related functions:
rerun.is_enabled
,rerun.get_recording_id
, ... - Sink-related functions:
rerun.connect
,rerun.spawn
, ... - Time-related functions:
rerun.set_time_seconds
,rerun.set_time_sequence
, ... - Log-related functions:
rerun.log_points
,rerun.log_mesh_file
, ...
For an exhaustive list, see help(rerun.RecordingStream)
.
Micro-batching
Micro-batching using both space and time triggers (whichever comes first) is done automatically in a dedicated background thread.
You can configure the frequency of the batches using the following environment variables:
RERUN_FLUSH_TICK_SECS
: Flush frequency in seconds (default:0.05
(50ms)).RERUN_FLUSH_NUM_BYTES
: Flush threshold in bytes (default:1048576
(1MiB)).RERUN_FLUSH_NUM_ROWS
: Flush threshold in number of rows (default:18446744073709551615
(u64::MAX)).
def is_enabled(recording=None)
Is this Rerun recording enabled.
If false, all calls to the recording are ignored.
The default can be set in rerun.init
, but is otherwise True
.
This can be controlled with the environment variable RERUN
(e.g. RERUN=on
or RERUN=off
).
def get_application_id(recording=None)
Get the application ID that this recording is associated with, if any.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recording |
RecordingStream | None
|
Specifies the |
None
|
Returns:
Type | Description |
---|---|
str
|
The application ID that this recording is associated with. |
def get_recording_id(recording=None)
Get the recording ID that this recording is logging to, as a UUIDv4, if any.
The default recording_id is based on multiprocessing.current_process().authkey
which means that all processes spawned with multiprocessing
will have the same default recording_id.
If you are not using multiprocessing
and still want several different Python
processes to log to the same Rerun instance (and be part of the same recording),
you will need to manually assign them all the same recording_id.
Any random UUIDv4 will work, or copy the recording id for the parent process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recording |
RecordingStream | None
|
Specifies the |
None
|
Returns:
Type | Description |
---|---|
str
|
The recording ID that this recording is logging to. |
def get_data_recording(recording=None)
Returns the most appropriate recording to log data to, in the current context, if any.
- If
recording
is specified, returns that one; - Otherwise, falls back to the currently active thread-local recording, if there is one;
- Otherwise, falls back to the currently active global recording, if there is one;
- Otherwise, returns None.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recording |
RecordingStream | None
|
Specifies the |
None
|
Returns:
Type | Description |
---|---|
Optional[RecordingStream]
|
The most appropriate recording to log data to, in the current context, if any. |
def get_global_data_recording()
Returns the currently active global recording, if any.
Returns:
Type | Description |
---|---|
Optional[RecordingStream]
|
The currently active global recording, if any. |
def set_global_data_recording(recording)
Replaces the currently active global recording with the specified one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recording |
RecordingStream
|
The newly active global recording. |
required |
def get_thread_local_data_recording()
Returns the currently active thread-local recording, if any.
Returns:
Type | Description |
---|---|
Optional[RecordingStream]
|
The currently active thread-local recording, if any. |
def set_thread_local_data_recording(recording)
Replaces the currently active thread-local recording with the specified one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recording |
RecordingStream
|
The newly active thread-local recording. |
required |