Skip to content

Improve rerun.notebook.Viewer constructor #9495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2025
Merged

Conversation

jprochazk
Copy link
Member

@jprochazk jprochazk commented Apr 4, 2025

For a while now, the use_global_recording param of rr.notebook.Viewer didn't actually do as advertised. Setting it to False would make the Viewer constructor ignore (almost) all other parameters.

The original intent for that parameter was to allow creating a completely empty Viewer. The new behavior is:

  • use_global_recording defaults to False if a url is provided.
  • use_global_recording defaults to True otherwise.
  • If no explicit recording is provided, and use_global_recording is True, then we use get_data_recording to pick up either the thread-local or global recording.

This means it is now possible to create a completely empty Viewer, and that is the default behavior given no params, and no global recording:

import rerun as rr

rr.notebook.Viewer()

If a url is provided, then by default we only show that url:

import rerun as rr

rr.notebook.Viewer(url="https://app.rerun.io/version/nightly/examples/arkit_scenes.rrd")

Using both a url and either an explicit/global recording is still possible:

import rerun as rr

rec = rr.RecordingStream("rerun_example_dual_recording")
rr.notebook.Viewer(
  url="https://app.rerun.io/version/nightly/examples/arkit_scenes.rrd",
  recording=rec,
)

# alternatively, call `add_recording` later:
rec = rr.RecordingStream("rerun_example_dual_recording")
viewer = rr.notebook.Viewer(
  url="https://app.rerun.io/version/nightly/examples/arkit_scenes.rrd",
)
viewer.add_recording(rec)
viewer.display()

# or just let it pick up the global recording:
rr.init("rerun_example_global_recording_notebook")
rr.notebook.Viewer(
  url="https://app.rerun.io/version/nightly/examples/arkit_scenes.rrd",
  use_global_recording=True,
)

If no url is provided, we pick up the global recording by default, but it can be turned off:

import rerun as rr

rr.init("rerun_example_global_recording_notebook")
rr.notebook.Viewer() # uses global recording

rr.init("rerun_example_global_recording_notebook")
rr.notebook.Viewer(use_global_recording=False) # will be empty

also allow not providing any inputs, resulting in an empty viewer

fix cube notebook example
@jprochazk jprochazk changed the title Fix use_global_recording param on rerun.notebook.Viewer Improve rerun.notebook.Viewer constructor Apr 4, 2025
@jprochazk jprochazk added 🪳 bug Something isn't working notebook Jupyter notebooks etc include in changelog labels Apr 4, 2025
@Wumpf Wumpf self-requested a review April 4, 2025 15:18
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, way better! And thank you so much for updating the example notebook

@jprochazk jprochazk merged commit 2d3e9cf into main Apr 4, 2025
34 checks passed
@jprochazk jprochazk deleted the jan/fix-viewer-init branch April 4, 2025 15:32
@emilk emilk mentioned this pull request Apr 11, 2025
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working include in changelog notebook Jupyter notebooks etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants