Skip to content

Notebook

rerun.notebook

Helper functions for converting streams to inline html.

class Viewer

A viewer embeddable in a notebook.

This viewer is a wrapper around the rerun_notebook.Viewer widget.

def __init__(*, width=None, height=None, url=None, blueprint=None, recording=None, use_global_recording=None)

Create a new Rerun viewer widget for use in a notebook.

Any data logged to the recording after initialization will be sent directly to the viewer.

This widget can be displayed by returning it at the end of your cells execution, or immediately by calling rerun.notebook.Viewer.display.

PARAMETER DESCRIPTION
width

The width of the viewer in pixels, or "auto".

When set to "auto", scales to 100% of the notebook cell's width.

TYPE: int | Literal['auto'] | None DEFAULT: None

height

The height of the viewer in pixels, or "auto".

When set to "auto", scales using a 16:9 aspect ratio with width.

TYPE: int | Literal['auto'] | None DEFAULT: None

url

Optional URL passed to the viewer for displaying its contents.

TYPE: str | None DEFAULT: None

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.

TYPE: RecordingStream | None DEFAULT: None

blueprint

A blueprint object to send to the viewer. It will be made active and set as the default blueprint in the recording.

Setting this is equivalent to calling rerun.send_blueprint before initializing the viewer.

TYPE: BlueprintLike | None DEFAULT: None

use_global_recording

If no explicit recording is provided, the Viewer uses the thread-local/global recording created by rr.init or set explicitly via rr.set_thread_local_data_recording/rr.set_global_data_recording.

Settings this to False causes the Viewer to not pick up the global recording.

Defaults to False if url is provided, and True otherwise.

TYPE: bool | None DEFAULT: None

def add_recording(recording=None, blueprint=None)

Adds a recording to the viewer.

If no recording is specified, the current active recording will be used.

NOTE: By default all calls to rr.init() will re-use the same recording_id, meaning that your recordings will be merged together. If you want to keep them separate, you should call rr.init("my_app_id", recording_id=uuid.uuid4()).

PARAMETER DESCRIPTION
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.

TYPE: RecordingStream DEFAULT: None

blueprint

A blueprint object to send to the viewer. It will be made active and set as the default blueprint in the recording.

Setting this is equivalent to calling rerun.send_blueprint before initializing the viewer.

TYPE: BlueprintLike DEFAULT: None

def close_url(url)

Close an open URL in the viewer.

Does nothing if the URL is not open.

PARAMETER DESCRIPTION
url

The URL to close.

TYPE: str

def display(block_until_ready=False)

Display the viewer in the notebook cell immediately.

PARAMETER DESCRIPTION
block_until_ready

Whether to block until the viewer is ready to receive data. If this is False, the viewer will still be displayed, but logged data will likely be queued until the viewer becomes ready at the end of cell execution.

TYPE: bool DEFAULT: False

def open_url(url)

Open a URL in the viewer.

PARAMETER DESCRIPTION
url

The URL to open.

Must point to a valid data source.

TYPE: str

def send_table(id, table)

Sends a table in the form of a dataframe to the viewer.

PARAMETER DESCRIPTION
id

The name that uniquely identifies the table in the viewer. This name will also be shown in the recording panel.

TYPE: str

table

The table as a single Arrow record batch.

TYPE: RecordBatch

def set_active_recording(*, recording_id)

Set the active recording for the viewer.

This is equivalent to clicking on the given recording in the blueprint panel.

PARAMETER DESCRIPTION
recording_id

The ID of the recording to set the viewer to.

Using this requires setting an explicit recording ID when creating the recording.

TYPE: str

def set_application_blueprint(application_id, blueprint, *, make_active=True, make_default=True)

Set the blueprint for the given application.

PARAMETER DESCRIPTION
application_id

The ID of the application to set the blueprint for.

TYPE: str

blueprint

The blueprint to set for the application.

TYPE: BlueprintLike

make_active

Whether to make the blueprint active. If True, the blueprint will be set as the active blueprint for the application.

TYPE: bool DEFAULT: True

make_default

Whether to make the blueprint the default blueprint for the application. If True, the blueprint will be set as the default blueprint for the application.

TYPE: bool DEFAULT: True

def set_time_ctrl(*, sequence=None, duration=None, timestamp=None, timeline=None, play=False)

Set the time control for the viewer.

You are expected to set at most ONE of the arguments sequence, duration, or timestamp.

PARAMETER DESCRIPTION
sequence

Used for sequential indices, like frame_nr. Must be an integer.

TYPE: int | None DEFAULT: None

duration

Used for relative times, like time_since_start. Must either be in seconds, a datetime.timedelta, or numpy.timedelta64. For nanosecond precision, use numpy.timedelta64(nanoseconds, 'ns').

TYPE: int | float | timedelta | timedelta64 | None DEFAULT: None

timestamp

Used for absolute time indices, like capture_time. Must either be in seconds since Unix epoch, a datetime.datetime, or numpy.datetime64. For nanosecond precision, use numpy.datetime64(nanoseconds, 'ns').

TYPE: int | float | datetime | datetime64 | None DEFAULT: None

play

Whether to start playing from the specified time point. Defaults to paused.

TYPE: bool DEFAULT: False

timeline

The name of the timeline to switch to. If not provided, time will remain on the current timeline.

TYPE: str | None DEFAULT: None

def update_panels(*, top=None, blueprint=None, selection=None, time=None)

Partially update the state of panels in the viewer.

Valid states are the strings expanded, collapsed, hidden, default, and the value None.

Panels set to: - None will be unchanged. - expanded will be fully expanded, taking up the most space. - collapsed will be smaller and simpler, omitting some information. - hidden will be completely invisible, taking up no space. - default will be reset to the default state.

The collapsed state is the same as the hidden state for panels which do not support the collapsed state.

Setting the panel state using this function will also prevent the user from modifying that panel's state in the viewer.

PARAMETER DESCRIPTION
top

State of the panel, positioned on the top of the viewer.

TYPE: _PanelState | Literal['default'] | None DEFAULT: None

blueprint

State of the blueprint panel, positioned on the left side of the viewer.

TYPE: _PanelState | Literal['default'] | None DEFAULT: None

selection

State of the selection panel, positioned on the right side of the viewer.

TYPE: _PanelState | Literal['default'] | None DEFAULT: None

time

State of the time panel, positioned on the bottom side of the viewer.

TYPE: _PanelState | Literal['default'] | None DEFAULT: None

def set_default_size(*, width, height)

Set the default size for the viewer.

This will be used for any viewers created after this call.

PARAMETER DESCRIPTION
width

The width of the viewer in pixels.

TYPE: int

height

The height of the viewer in pixels.

TYPE: int