Skip to content
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

Make it possible to configure how rerun_notebook fetches the widget #6680

Merged
merged 11 commits into from
Jul 1, 2024

Conversation

jleibs
Copy link
Member

@jleibs jleibs commented Jun 28, 2024

What

Overview

Even though rerun_notebook ships with the widget asset bundled in, by default it will try to load the asset
from https://app.rerun.io. This is because the way anywiget transmits the asset at the moment results in
a memory leak of the entire module for each cell execution.

If your network does not allow you to access app.rerun.io, the behavior can be changed by setting the
the RERUN_NOTEBOOK_ASSET environment variable before you import rerun_notebook. This variable must
be set prior to your import because AnyWidget stores the resource on the widget class instance
once at import time.

Inlined asset

Setting:

RERUN_NOTEBOOK_ASSET=inline

Will cause rerun_notebook to directly transmit the inlined asset to the widget over Jupyter comms.
This will be the most portable way to use the widget, but is currently known to leak memory and
has some performance issues in environments such as Google colab.

Locally served asset

Setting:

RERUN_NOTEBOOK_ASSET=serve-local

Will cause rerun_notebook to launch a thread serving the asset from the local machine during
the lifetime of the kernel. This will be the best way to use the widget in a notebook environment
when your notebook server is running locally.

Manually hosted asset

Setting:

RERUN_NOTEBOOK_ASSET=https://your-hosted-asset-url.com/widget.js

Will cause rerun_notebook to load the asset from the provided URL. This is the most flexible way to
use the widget, but requires you to host the asset yourself.

The rerun_notebook package has a minimal server that can be used to serve the asset nanually by running:

python -m rerun_notebook serve

However, any hosting platform can be used to serve the asset, as long as it is accessible to the notebook
and has appropriate CORS headers set. asset_server.py for a simple example.

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!

To run all checks from main, comment on the PR with @rerun-bot full-check.

@jleibs jleibs marked this pull request as ready for review June 28, 2024 17:26
@jleibs jleibs added notebook Jupyter notebooks etc exclude from changelog PRs with this won't show up in CHANGELOG.md labels Jun 28, 2024
@jleibs jleibs force-pushed the jleibs/notebook_asset_plumbing branch from a091f81 to b800fd5 Compare June 28, 2024 17:27
@emilk
Copy link
Member

emilk commented Jun 28, 2024

Is it possible to print an error message pointing the user to RERUN_NOTEBOOK_ASSET if they fail to load the viewer from app.rerun.io?

Copy link

github-actions bot commented Jun 28, 2024

Deployed docs

Commit Link
8d1213b https://landing-1lm6a04il-rerun.vercel.app/docs

@jprochazk jprochazk merged commit db2251a into main Jul 1, 2024
39 of 40 checks passed
@jprochazk jprochazk deleted the jleibs/notebook_asset_plumbing branch July 1, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude from changelog PRs with this won't show up in CHANGELOG.md notebook Jupyter notebooks etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The new self-contained widget is slow in google colab
3 participants