Skip to content

[jupyter] introduce %rootbrowse magic#21761

Merged
linev merged 16 commits intoroot-project:masterfrom
linev:jupyter_new
Apr 21, 2026
Merged

[jupyter] introduce %rootbrowse magic#21761
linev merged 16 commits intoroot-project:masterfrom
linev:jupyter_new

Conversation

@linev
Copy link
Copy Markdown
Member

@linev linev commented Apr 1, 2026

First of all - refactor jupyter drawer codes to make separate classes for TCanvas, RCanvas, TGeoManager, TFile

Introduce rootbrowse magic in cpp and python kernels. It works like:

rootbrowse

By default file is opened and shown in JSROOT page.
One can specify -f option to force opening of large files. By default file up to 10MB can be viewed.

Special handling for http:// / https:// files. JSROOT can load such files directly - so there is no need to load full file content first. So size limitation is not important for such files - while JSROOT uses partial I/O

Supersede #21364

linev added 11 commits April 1, 2026 10:25
In the NotebookDrawer implement handling of the TFile instance.
Full file content read in binary buffer and injected into HTML page
as base64-coded blob. In the JavaScript blob encoded back and
HierarchyPainter used to implement file content browsing.

File size limited by 10MB. Bigger files only can be drawn when
file.Draw("force") is invoked.

Fix problem with geometry display
Keep the only enableJSVis function to switch magic via `%jsroot on/off`
This is preparation to split functionality in subclasses
…file

So one clearly separate functionality.
Change slightly interface to be able reuse drawers.Draw
function in python and C++ kernel in the same manner
Use specialized method in dedicated Drawer class
Need to be executed when %rootbrowse magic is used
Let open large files in python kernel
@linev linev self-assigned this Apr 1, 2026
@linev linev changed the title [jupyter] introduce rootbrowse magic [jupyter] introduce %rootbrowse magic Apr 1, 2026
Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py Outdated
linev added 2 commits April 1, 2026 11:17
While JSROOT able to load files via http/https protocol, just delegate this work to it.
Only if -f flag specified, ROOT TFile will be used to load file content.
Only when Draw function is invoked - try to open and read file.
At this place one can have better possibility to display errors
Copy link
Copy Markdown
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

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

Thank you, this is an interesting addition to the Jupyter notebook capabilities! A first round of comments from my side.

Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py Outdated
Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py Outdated
Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py Outdated
Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py Outdated
Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py Outdated
Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/magics/rootbrowsemagic.py Outdated
Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py Outdated
Comment thread bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py Outdated
Use `with ROOT.TDirectory.TContext()`
Update comments
Simplify class declarations
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

Test Results

    22 files      22 suites   3d 4h 48m 42s ⏱️
 3 833 tests  3 782 ✅  1 💤 50 ❌
76 555 runs  76 487 ✅ 18 💤 50 ❌

For more details on these failures, see this check.

Results for commit 09e5897.

♻️ This comment has been updated with latest results.

@dpiparo
Copy link
Copy Markdown
Member

dpiparo commented Apr 10, 2026

It's not the same environment, but would it be feasible to have the browser as a window of jupyterlab?

@linev
Copy link
Copy Markdown
Member Author

linev commented Apr 10, 2026

It's not the same environment, but would it be feasible to have the browser as a window of jupyterlab?

You mean TBrowser? Or better to say web-based RBrowser?

Copy link
Copy Markdown
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

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

The code works and the changes look alright, maybe except for the usage of global which should be avoided but it's not been introduced by this PR specifically.

I left a final comment before merging, this being a new feature it should probably be communicated very explicitly to users at least for the moment.

@linev
Copy link
Copy Markdown
Member Author

linev commented Apr 16, 2026

@vepadulano

I do not like usage of warnings here.
Produced output is looks as error and not as gentle message to users.

warnings

I will revert last commit.

@linev linev requested a review from vepadulano April 16, 2026 11:02
@dpiparo dpiparo self-requested a review April 21, 2026 09:16
@linev linev dismissed vepadulano’s stale review April 21, 2026 10:25

One should find better way to show info about new feature and contact url.
Can be done in extra PR

@linev linev merged commit efd9b1d into root-project:master Apr 21, 2026
75 of 82 checks passed
@linev linev deleted the jupyter_new branch April 21, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants