Error with JSROOT when uploading generated HTML Jupyter notebooks to website

Hello,

I would like to publish some notebooks as HTML files on our website, the same way as it’s done here: https://swan.web.cern.ch/content/basic-examples

I’m using nbconvert to convert from .ipynb to .html, but I’m getting no JSROOT output. The reason seems that my website is trying to find JSROOT scripts from a local directory rather than from the ROOT domain:

requirejs.config({
     paths: {
       'JSRootCore' : '/static/scripts/JSRootCore',
     }
   });

Whereas, on the SWAN examples page it points to the online scripts:

 requirejs.config({
     paths: {
       'JSRootCore' : 'https://root.cern.ch/js/notebook//scripts/JSRootCore',
     }
   });

Am I missing a step to tell nbconvert to use the scripts from root.cern.ch?

@linev, I believe you are most familiar with JSROOT. Do you have a clue what is going wrong?

Cheers,
Ahmad

Edit: here is the link to our published notebook: https://biodynamo.org/notebooks/cell_division.html


ROOT Version: 6.18/04


Hi,

Notebook using JSROOT from static location, provided from ROOT installation.
If you want to publish HTML files, you have to replace static location by some public URL - it can be https://root.cern.ch/js/notebook/ (as on SWAN) or any particular release like https://root.cern.ch/js/5.8.0/. In ideal case you need to copy JSROOT from ROOT installation to your web server and use it - this guarantee compatibility between generated JSON data and JSROOT scripts.

Regards,
Sergey

Ah okay, I think copying JSROOT to my web server would be indeed the more ideal case. Would I just have to copy the root/js/scripts/ folder to my website’s /static folder?

You need to copy full content of $ROOTSYS/js/ folder to /static folder of your web server - in this case HTML can be kept as is.

Thanks I will try out now and let you know!

Even after adding the contents of $ROOTSYS/js to the /static folder of my web server, I still get no visualization output: https://biodynamo.org/notebooks/cell_division.html. Is there another missing step?

A difference between my use case and the SWAN gallery examples is that I don’t use nbviewer to host the notebooks, but rather I store the html files directly on our server. The console output of the abovementioned website complains about “requirejs” missing.

Hi,

If you open web browser console (Ctrl+Shift+I), you will see error messages.
First, you are missing https://biodynamo.org/static/scripts/JSRootCore.js
Also one needs https://biodynamo.org/static/components/requirejs/require.js

Regards,
Sergey

Hi,

Ok, I also added require.js to the appropriate directory. I thought that would solve it, but unfortunately not:

The missing custom.css should not be the issue; I am also getting that when I open the notebook locally (and the JSROOT visualization works). Do you have any more suggestions on what I can try here?

Cheers,
Ahmad

Hi,

Now loading of scripts worked, but you facing error in 6.22.00 release.
Please apply simple fix described here: Jupyter notebook with ROOT C++ kernal in WSL

Regards,
Sergey

1 Like

Thanks, it’s working now :grin:

For those that need to apply this patch in a bash script, this is the sed command I’m using to do so:

if [ $($ROOTSYS/bin/root-config --version) == "6.22/00" ]; then
  sed -i -e 's/JSROOT.gStyle, style/JSROOT.gStyle, obj/g' ${ROOTSYS}/js/scripts/JSRootPainter.v6.js
fi

I hope, we will have patched 6.22.02 version soon - approx mid of August

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.