ROOT.enableJSVis() in a "ROOT flavour" notebook

Dear ROOTers,

I am testing the new ROOT6.06 notebook feature. I used the binaries for my CC7 and gcc 4.8 and it worked without much effort.

How do I enable the “interactive canvas” if I am using a “ROOT flavored” notebook? In your example (root.cern.ch/notebooks/HowTos/H … books.html) you mention only the “Python” version:
ROOT.enableJSVis()

Thanks in advance,
Matteo

Hi Matteo,

you can do this with

TPython::Exec("ROOT.enableJSVis()")

Please note that the JS visualisation within notebooks is still considered “experimental”. Discussions about if / how making it the default visualisation will take place at the beginning of next year.

Cheers,
Danilo

I have tried this in the master branch, but I get a segmentation violation and kernel restart. Am I doing something wrong?

TPython::Exec("ROOT.enableJSVis()");


 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================

Thread 8 (Thread 0x7efce88fc700 (LWP 19228)):
#0  0x00007efcfa254f83 in epoll_wait () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007efcea87827c in zmq::epoll_t::loop (this=0x12f7ff0) at bundled/zeromq/src/epoll.cpp:156
#2  0x00007efcea87e68a in thread_routine (arg_=0x12f8070) at bundled/zeromq/src/thread.cpp:96
#3  0x00007efcfae3e284 in start_thread (arg=0x7efce88fc700) at pthread_create.c:333
#4  0x00007efcfa25497d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 7 (Thread 0x7efce80fb700 (LWP 19229)):
#0  0x00007efcfa254f83 in epoll_wait () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007efcea87827c in zmq::epoll_t::loop (this=0xc1a240) at bundled/zeromq/src/epoll.cpp:156
#2  0x00007efcea87e68a in thread_routine (arg_=0xc1a2c0) at bundled/zeromq/src/thread.cpp:96
#3  0x00007efcfae3e284 in start_thread (arg=0x7efce80fb700) at pthread_create.c:333
#4  0x00007efcfa25497d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 6 (Thread 0x7efce78fa700 (LWP 19230)):
#0  0x00007efcfa24ba9d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007efcea86db9b in poll (__timeout=<optimized out>, __nfds=2, __fds=0x7efce78f9480) at /usr/include/x86_64-linux-gnu/bits/poll2.h:46
#2  zmq_poll (items_=items_
entry=0x7efce78f95b0, nitems_=nitems_
entry=2, timeout_=timeout_
entry=-1) at bundled/zeromq/src/zmq.cpp:755
#3  0x00007efcea882d53 in zmq::proxy (frontend_=0x7efce0003500, backend_=0x7efce0003500, capture_=capture_
entry=0x0, control_=control_
entry=0x0) at bundled/zeromq/src/proxy.cpp:140
#4  0x00007efcea86deb9 in zmq_proxy (frontend_=<optimized out>, backend_=<optimized out>, capture_=capture_
entry=0x0) at bundled/zeromq/src/zmq.cpp:1040
#5  0x00007efce958f629 in __pyx_pf_3zmq_7backend_6cython_7_device_2proxy (__pyx_self=<optimized out>, __pyx_v_frontend=<optimized out>, __pyx_v_backend=<optimized out>, __pyx_v_capture=<optimized out>) at zmq/backend/cython/_device.c:1452
#6  __pyx_pw_3zmq_7backend_6cython_7_device_3proxy (__pyx_self=<optimized out>, __pyx_args=<optimized out>, __pyx_kwds=<optimized out>) at zmq/backend/cython/_device.c:1339
#7  0x00007efce9591309 in __Pyx_PyObject_Call (kw=0x0, arg=0x7efce8bab950, func=0x7efce9fc8998) at zmq/backend/cython/_device.c:2541
#8  __pyx_pf_3zmq_7backend_6cython_7_device_device (__pyx_self=<optimized out>, __pyx_v_device_type=<optimized out>, __pyx_v_backend=0x7efce8938c18, __pyx_v_frontend=<optimized out>) at zmq/backend/cython/_device.c:1035
#9  __pyx_pw_3zmq_7backend_6cython_7_device_1device (__pyx_self=<optimized out>, __pyx_args=<optimized out>, __pyx_kwds=<optimized out>) at zmq/backend/cython/_device.c:962
#10 0x00000000004bbc2a in PyEval_EvalFrameEx ()
#11 0x00000000004c0bef in PyEval_EvalFrameEx ()
#12 0x00000000004c0bef in PyEval_EvalFrameEx ()
#13 0x00000000004b9416 in PyEval_EvalCodeEx ()
#14 0x00000000004d5269 in ?? ()
#15 0x00000000004edbce in ?? ()
#16 0x00000000004a5eee in PyObject_Call ()
#17 0x00000000004c5810 in PyEval_CallObjectWithKeywords ()
#18 0x000000000058a112 in ?? ()
#19 0x00007efcfae3e284 in start_thread (arg=0x7efce78fa700) at pthread_create.c:333
#20 0x00007efcfa25497d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 5 (Thread 0x7efce70b9700 (LWP 19231)):
#0  0x00007efcfa254f83 in epoll_wait () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007efcea87827c in zmq::epoll_t::loop (this=0x7efce0002dc0) at bundled/zeromq/src/epoll.cpp:156
#2  0x00007efcea87e68a in thread_routine (arg_=0x7efce0002e40) at bundled/zeromq/src/thread.cpp:96
#3  0x00007efcfae3e284 in start_thread (arg=0x7efce70b9700) at pthread_create.c:333
#4  0x00007efcfa25497d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 4 (Thread 0x7efce68b8700 (LWP 19232)):
#0  0x00007efcfa254f83 in epoll_wait () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007efcea87827c in zmq::epoll_t::loop (this=0x7efce0003290) at bundled/zeromq/src/epoll.cpp:156
#2  0x00007efcea87e68a in thread_routine (arg_=0x7efce0003310) at bundled/zeromq/src/thread.cpp:96
#3  0x00007efcfae3e284 in start_thread (arg=0x7efce68b8700) at pthread_create.c:333
#4  0x00007efcfa25497d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 3 (Thread 0x7efce5e53700 (LWP 19298)):
#0  0x00007efcfa24d893 in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x000000000058a5a8 in ?? ()
#2  0x00000000004bbc2a in PyEval_EvalFrameEx ()
#3  0x00000000004c0bef in PyEval_EvalFrameEx ()
#4  0x00000000004c0bef in PyEval_EvalFrameEx ()
#5  0x00000000004b9416 in PyEval_EvalCodeEx ()
#6  0x00000000004d5269 in ?? ()
#7  0x00000000004edbce in ?? ()
#8  0x00000000004a5eee in PyObject_Call ()
#9  0x00000000004c5810 in PyEval_CallObjectWithKeywords ()
#10 0x000000000058a112 in ?? ()
#11 0x00007efcfae3e284 in start_thread (arg=0x7efce5e53700) at pthread_create.c:333
#12 0x00007efcfa25497d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 2 (Thread 0x7efce5652700 (LWP 19300)):
#0  0x00007efcfa22400b in __GI___waitpid (pid=19303, stat_loc=stat_loc
entry=0x7efce564e560, options=options
entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
#1  0x00007efcfa1ab49b in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2  0x00007efcf5ac4a99 in TUnixSystem::StackTrace (this=0xbdc100) at /opt/root6/root6_src/core/unix/src/TUnixSystem.cxx:2318
#3  0x00007efcf5ac71dc in TUnixSystem::DispatchSignals (this=0xbdc100, sig=kSigSegmentationViolation) at /opt/root6/root6_src/core/unix/src/TUnixSystem.cxx:3556
#4  <signal handler called>
#5  0x000000000049e41b in PyImport_AddModule ()
#6  0x00007efcf75ee614 in TPython::Initialize () at /opt/root6/root6_src/bindings/pyroot/src/TPython.cxx:129
#7  0x00007efcf75eebb0 in TPython::Exec (cmd=0x7efcfb247000 "ROOT.enableJSVis()") at /opt/root6/root6_src/bindings/pyroot/src/TPython.cxx:342
#8  0x00007efcfb24803e in ?? ()
#9  0x00007efc00000001 in ?? ()
#10 0x000000000106a460 in ?? ()
#11 0x00007efce5650c50 in ?? ()
#12 0x00007efce5650fa0 in ?? ()
#13 0x00000000010666c0 in ?? ()
#14 0x00007efce5650fa0 in ?? ()
#15 0x00007efce5650c50 in ?? ()
#16 0x00007efcf24a9aa3 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) () from /opt/root6/lib/libCling.so
#17 0x00007efcf24af017 in cling::Interpreter::EvaluateInternal(std::string const&, cling::CompilationOptions, cling::Value*, cling::Transaction**) () from /opt/root6/lib/libCling.so
#18 0x00007efcf24af153 in cling::Interpreter::process(std::string const&, cling::Value*, cling::Transaction**) () from /opt/root6/lib/libCling.so
#19 0x00007efcf2542193 in cling::MetaProcessor::process(char const*, cling::Interpreter::CompilationResult&, cling::Value*) () from /opt/root6/lib/libCling.so
#20 0x00007efcf241afd6 in HandleInterpreterException (metaProcessor=<optimized out>, input_line=<optimized out>, compRes=
0x7efce5650ebc: cling::Interpreter::kSuccess, result=result
entry=0x7efce5650fa0) at /opt/root6/root6_src/core/meta/src/TCling.cxx:1843
#21 0x00007efcf242be46 in TCling::ProcessLine (this=0x1065f20, line=<optimized out>, error=0x7efce565122c) at /opt/root6/root6_src/core/meta/src/TCling.cxx:1999
#22 0x00007efce897e819 in JupyROOTExecutorImpl (code=0x7efce70d4af4 "TPython::Exec(\"ROOT.enableJSVis()\");") at /opt/root6/root6_src/bindings/pyroot/JupyROOT/src/IOHandler.cxx:120
#23 0x00007efce897e8b9 in JupyROOTExecutor (code=<optimized out>) at /opt/root6/root6_src/bindings/pyroot/JupyROOT/src/IOHandler.cxx:152
#24 0x00007efcf7896060 in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#25 0x00007efcf7895acb in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#26 0x00007efcf7aa63e1 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#27 0x00007efcf7aaad72 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#28 0x00000000004c0e4d in PyEval_EvalFrameEx ()
#29 0x00000000004b9416 in PyEval_EvalCodeEx ()
#30 0x00000000004d53a3 in ?? ()
#31 0x00000000004a5eee in PyObject_Call ()
#32 0x00000000004c2858 in PyEval_EvalFrameEx ()
#33 0x00000000004c0bef in PyEval_EvalFrameEx ()
#34 0x00000000004c0bef in PyEval_EvalFrameEx ()
#35 0x00000000004b9416 in PyEval_EvalCodeEx ()
#36 0x00000000004d5269 in ?? ()
#37 0x00000000004edbce in ?? ()
#38 0x00000000004a5eee in PyObject_Call ()
#39 0x00000000004c5810 in PyEval_CallObjectWithKeywords ()
#40 0x000000000058a112 in ?? ()
#41 0x00007efcfae3e284 in start_thread (arg=0x7efce5652700) at pthread_create.c:333
#42 0x00007efcfa25497d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Thread 1 (Thread 0x7efcfb23c700 (LWP 19208)):
#0  0x00007efcfa24d893 in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x000000000058a5a8 in ?? ()
#2  0x00000000004bbc2a in PyEval_EvalFrameEx ()
#3  0x00000000004b9416 in PyEval_EvalCodeEx ()
#4  0x00000000004c0f7a in PyEval_EvalFrameEx ()
#5  0x00000000004b9416 in PyEval_EvalCodeEx ()
#6  0x00000000004c0f7a in PyEval_EvalFrameEx ()
#7  0x00000000004b9416 in PyEval_EvalCodeEx ()
#8  0x00000000004c0f7a in PyEval_EvalFrameEx ()
#9  0x00000000004b9416 in PyEval_EvalCodeEx ()
#10 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#11 0x00000000004b9416 in PyEval_EvalCodeEx ()
#12 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#13 0x00000000004b9416 in PyEval_EvalCodeEx ()
#14 0x00000000004d53a3 in ?? ()
#15 0x00000000004a5eee in PyObject_Call ()
#16 0x00000000004c2858 in PyEval_EvalFrameEx ()
#17 0x00000000004b9416 in PyEval_EvalCodeEx ()
#18 0x00000000004d53a3 in ?? ()
#19 0x00000000004a5eee in PyObject_Call ()
#20 0x00000000004c2858 in PyEval_EvalFrameEx ()
#21 0x00000000004b9416 in PyEval_EvalCodeEx ()
#22 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#23 0x00000000004b9416 in PyEval_EvalCodeEx ()
#24 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#25 0x00000000004b9416 in PyEval_EvalCodeEx ()
#26 0x00000000004d53a3 in ?? ()
#27 0x00000000004a5eee in PyObject_Call ()
#28 0x00000000004c2858 in PyEval_EvalFrameEx ()
#29 0x00000000004b9416 in PyEval_EvalCodeEx ()
#30 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#31 0x00000000004b9416 in PyEval_EvalCodeEx ()
#32 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#33 0x00000000004b9416 in PyEval_EvalCodeEx ()
#34 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#35 0x00000000004b9416 in PyEval_EvalCodeEx ()
#36 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#37 0x00000000004b9416 in PyEval_EvalCodeEx ()
#38 0x00000000004c0f7a in PyEval_EvalFrameEx ()
#39 0x00000000004b9416 in PyEval_EvalCodeEx ()
#40 0x00000000004c16f3 in PyEval_EvalFrameEx ()
#41 0x00000000004b9416 in PyEval_EvalCodeEx ()
#42 0x00000000004bfadc in PyEval_EvalFrameEx ()
#43 0x00000000004b9416 in PyEval_EvalCodeEx ()
#44 0x00000000004c0f7a in PyEval_EvalFrameEx ()
#45 0x00000000004b9416 in PyEval_EvalCodeEx ()
#46 0x00000000004d5269 in ?? ()
#47 0x00000000004a5eee in PyObject_Call ()
#48 0x000000000051d646 in ?? ()
#49 0x0000000000492e29 in Py_Main ()
#50 0x00007efcfa18c870 in __libc_start_main (main=0x492830 <main>, argc=5, argv=0x7ffd963d2588, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffd963d2578) at libc-start.c:291
#51 0x0000000000492759 in _start ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x000000000049e41b in PyImport_AddModule ()
#6  0x00007efcf75ee614 in TPython::Initialize () at /opt/root6/root6_src/bindings/pyroot/src/TPython.cxx:129
#7  0x00007efcf75eebb0 in TPython::Exec (cmd=0x7efcfb247000 "ROOT.enableJSVis()") at /opt/root6/root6_src/bindings/pyroot/src/TPython.cxx:342
#8  0x00007efcfb24803e in ?? ()
#9  0x00007efc00000001 in ?? ()
#10 0x000000000106a460 in ?? ()
#11 0x00007efce5650c50 in ?? ()
#12 0x00007efce5650fa0 in ?? ()
#13 0x00000000010666c0 in ?? ()
#14 0x00007efce5650fa0 in ?? ()
#15 0x00007efce5650c50 in ?? ()
#16 0x00007efcf24a9aa3 in cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) () from /opt/root6/lib/libCling.so
#17 0x00007efcf24af017 in cling::Interpreter::EvaluateInternal(std::string const&, cling::CompilationOptions, cling::Value*, cling::Transaction**) () from /opt/root6/lib/libCling.so
#18 0x00007efcf24af153 in cling::Interpreter::process(std::string const&, cling::Value*, cling::Transaction**) () from /opt/root6/lib/libCling.so
#19 0x00007efcf2542193 in cling::MetaProcessor::process(char const*, cling::Interpreter::CompilationResult&, cling::Value*) () from /opt/root6/lib/libCling.so
#20 0x00007efcf241afd6 in HandleInterpreterException (metaProcessor=<optimized out>, input_line=<optimized out>, compRes=
0x7efce5650ebc: cling::Interpreter::kSuccess, result=result
entry=0x7efce5650fa0) at /opt/root6/root6_src/core/meta/src/TCling.cxx:1843
===========================================================


root --notebook
[I 17:59:49.254 NotebookApp] Serving notebooks from local directory: /tmp
[I 17:59:49.254 NotebookApp] 0 active kernels 
[I 17:59:49.254 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 17:59:49.254 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 17:59:55.766 NotebookApp] Kernel started: 20b99d47-1810-4f74-aaaf-8e3378a01d31
[I 18:00:16.844 NotebookApp] Creating new notebook in 
[I 18:00:18.187 NotebookApp] Kernel started: 9092a0ed-839a-4fe9-8964-ca15862226ed
[I 18:00:20.483 NotebookApp] Saving file at /Untitled.ipynb
(ErrorHandlerFunc_t) Function @0x7efcf75e4680


[I 18:00:26.532 NotebookApp] Kernel shutdown: 20b99d47-1810-4f74-aaaf-8e3378a01d31
[I 18:00:39.186 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 9092a0ed-839a-4fe9-8964-ca15862226ed restarted
(ErrorHandlerFunc_t) Function @0x7f19d8e95680


[I 18:02:18.436 NotebookApp] Saving file at /Untitled1.ipynb

Hi Matteo,

it was decided today to provide a magic command to enable js visualisation today. The new feature should appear in master soon and will be definitively there for root 6.08.
The crash with TPython is odd but I could reproduce it. I’ll provide a fix for it also.

Cheers,
Danilo

Nice, thanks.

Note that the crash is independent on what you write in the Notebook inside TPython.

TPython("");
also crashes.

Thanks matteo.

Any news on how to enable JSVis on ROOT flavoured notebooks?

Also, I think the documentation concerning C++ magic should be updated (%cpp instead of .cpp)
root.cern.ch/notebooks/HowTos/H … books.html

Thanks.

Hi,

thanks for your remark.
Starting from version 6.07.06 there is a single magic, both for python and C++:

%jsroot on [off]

The instructions on the site are being updated now.
This is still a development release and the information did not propagate yet to all documentation.

Cheers,
Danilo

Hi,

the relevant “how to” has been renovated: root.cern.ch/how/how-use-root-notebook

Cheers,
Danilo

1 Like