[jupyter] introduce %rootbrowse magic#21761
[jupyter] introduce %rootbrowse magic#21761linev wants to merge 16 commits intoroot-project:masterfrom
%rootbrowse magic#21761Conversation
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
rootbrowse magic%rootbrowse magic
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py
Outdated
Show resolved
Hide resolved
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
vepadulano
left a comment
There was a problem hiding this comment.
Thank you, this is an interesting addition to the Jupyter notebook capabilities! A first round of comments from my side.
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py
Outdated
Show resolved
Hide resolved
| if sz > 10000000 and self.drawOption != "force": | ||
| return f"File size {sz} is too large for JSROOT display. Use 'force' draw option to show file nevertheless" |
There was a problem hiding this comment.
I don't particularly like the word force, I believe it's not really easy to understand what it should be doing. I would consider something like drawLargeFile, DRAW_LARGE_FILE or a similar spelling. And the option for the rootbrowse should be then --draw-large-file, possibly shortened to -l for large? I am not sure yet what would be the best alternative.
There was a problem hiding this comment.
In following commits I add change with --force flag like %rootbrowse largefile.root -f
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py
Outdated
Show resolved
Hide resolved
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py
Outdated
Show resolved
Hide resolved
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py
Outdated
Show resolved
Hide resolved
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/magics/rootbrowsemagic.py
Outdated
Show resolved
Hide resolved
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/kernel/magics/rootbrowsemagic.py
Show resolved
Hide resolved
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/magics/rootbrowsemagic.py
Show resolved
Hide resolved
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py
Outdated
Show resolved
Hide resolved
bindings/pyroot/pythonizations/python/ROOT/_jupyroot/helpers/utils.py
Outdated
Show resolved
Hide resolved
Use `with ROOT.TDirectory.TContext()` Update comments Simplify class declarations
Test Results 22 files 22 suites 3d 8h 20m 1s ⏱️ For more details on these failures, see this check. Results for commit 09e5897. ♻️ This comment has been updated with latest results. |
Too old ROOT versions not supported by JSROOT
|
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? |
First of all - refactor jupyter drawer codes to make separate classes for TCanvas, RCanvas, TGeoManager, TFile
Introduce
rootbrowsemagic in cpp and python kernels. It works like:By default file is opened and shown in JSROOT page.
One can specify
-foption 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/OSupersede #21364