Notebook
rerun.notebook
Helper functions for converting streams to inline html.
ViewerEvent = PlayEvent | PauseEvent | TimeUpdateEvent | TimelineChangeEvent | SelectionChangeEvent | RecordingOpenEvent
module-attribute
Union type for all possible viewer event types.
SelectionItem = EntitySelectionItem | ViewSelectionItem | ContainerSelectionItem
module-attribute
Union type for all possible selection item types.
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. |
height
|
The height of the viewer in pixels, or "auto". When set to "auto", scales using a 16:9 aspect ratio with |
url
|
Optional URL passed to the viewer for displaying its contents.
TYPE:
|
recording
|
Specifies the
TYPE:
|
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
TYPE:
|
use_global_recording
|
If no explicit Settings this to Defaults to
TYPE:
|
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
TYPE:
|
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
TYPE:
|
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:
|
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
TYPE:
|
def on_event(callback)
Register a callback to be called when a viewer event occurs.
The callback will receive a ViewerEvent, which is one of:
PlayEvent, PauseEvent,
TimeUpdateEvent, TimelineChangeEvent,
SelectionChangeEvent, or RecordingOpenEvent.
| PARAMETER | DESCRIPTION |
|---|---|
callback
|
A function that takes a
TYPE:
|
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:
|
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:
|
table
|
The table data as an Arrow RecordBatch, list of RecordBatches, or a datafusion DataFrame.
TYPE:
|
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:
|
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:
|
blueprint
|
The blueprint to set for the application.
TYPE:
|
make_active
|
Whether to make the blueprint active.
If
TYPE:
|
make_default
|
Whether to make the blueprint the default blueprint for the application.
If
TYPE:
|
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
TYPE:
|
duration
|
Used for relative times, like
TYPE:
|
timestamp
|
Used for absolute time indices, like
TYPE:
|
play
|
Whether to start playing from the specified time point. Defaults to paused.
TYPE:
|
timeline
|
The name of the timeline to switch to. If not provided, time will remain on the current timeline.
TYPE:
|
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:
|
blueprint
|
State of the blueprint panel, positioned on the left side of the viewer.
TYPE:
|
selection
|
State of the selection panel, positioned on the right side of the viewer.
TYPE:
|
time
|
State of the time panel, positioned on the bottom side of the viewer.
TYPE:
|
class PlayEvent
dataclass
Bases: ViewerEventBase
Event triggered when the viewer starts playing.
application_id: str
instance-attribute
The application ID of the recording that triggered the event.
recording_id: str
instance-attribute
The recording ID of the recording that triggered the event.
segment_id: str | None
instance-attribute
The segment ID of the recording that triggered the event, if any.
class PauseEvent
dataclass
Bases: ViewerEventBase
Event triggered when the viewer pauses playback.
application_id: str
instance-attribute
The application ID of the recording that triggered the event.
recording_id: str
instance-attribute
The recording ID of the recording that triggered the event.
segment_id: str | None
instance-attribute
The segment ID of the recording that triggered the event, if any.
class TimeUpdateEvent
dataclass
Bases: ViewerEventBase
Event triggered when the current time changes in the viewer.
application_id: str
instance-attribute
The application ID of the recording that triggered the event.
recording_id: str
instance-attribute
The recording ID of the recording that triggered the event.
segment_id: str | None
instance-attribute
The segment ID of the recording that triggered the event, if any.
time: float
instance-attribute
The new time value.
class TimelineChangeEvent
dataclass
Bases: ViewerEventBase
Event triggered when the active timeline changes in the viewer.
application_id: str
instance-attribute
The application ID of the recording that triggered the event.
recording_id: str
instance-attribute
The recording ID of the recording that triggered the event.
segment_id: str | None
instance-attribute
The segment ID of the recording that triggered the event, if any.
time: float
instance-attribute
The current time value on the new timeline.
timeline: str
instance-attribute
The name of the new active timeline.
class SelectionChangeEvent
dataclass
Bases: ViewerEventBase
Event triggered when the selection changes in the viewer.
application_id: str
instance-attribute
The application ID of the recording that triggered the event.
items: list[SelectionItem]
instance-attribute
The list of currently selected items.
recording_id: str
instance-attribute
The recording ID of the recording that triggered the event.
segment_id: str | None
instance-attribute
The segment ID of the recording that triggered the event, if any.
class RecordingOpenEvent
dataclass
Bases: ViewerEventBase
Event triggered when a recording is opened in the viewer.
application_id: str
instance-attribute
The application ID of the recording that triggered the event.
recording_id: str
instance-attribute
The recording ID of the recording that triggered the event.
segment_id: str | None
instance-attribute
The segment ID of the recording that triggered the event, if any.
source: str
instance-attribute
The source of the recording (e.g. a URL or file path).
version: str | None
instance-attribute
The version of the recording, if available.
class EntitySelectionItem
dataclass
An entity selection item, representing a selected entity in the viewer.
entity_path: str
instance-attribute
The entity path of the selected entity.
instance_id: int | None = None
class-attribute
instance-attribute
The instance ID of the selected entity, if any.
position: list[float] | None = None
class-attribute
instance-attribute
The 3D position of the selection, if any.
view_name: str | None = None
class-attribute
instance-attribute
The name of the view containing the selected entity, if any.
class ViewSelectionItem
dataclass
A view selection item, representing a selected view in the viewer.
view_id: str
instance-attribute
The ID of the selected view.
view_name: str
instance-attribute
The name of the selected view.
class ContainerSelectionItem
dataclass
A container selection item, representing a selected container in the viewer.
container_id: str
instance-attribute
The ID of the selected container.
container_name: str
instance-attribute
The name of the selected container.