Failed to execute template. Cause: [Access denied when checking [script] access to [xwiki:Collaboratory.UX.HbpSkin.WebHome] for user [xwiki:XWiki.Admin]]. Click on this message for details.

Add a notebook in a wiki page - HBP Wiki

IAM21 instance, do not create collab nor modify a team, your changes will be lost


Add a notebook in a wiki page

Last modified by hbpadmin on 2023/05/15 15:08

This is a minimal viable feature of the Collaboratory. It is work in progress. We plan to make it more user friendly in the future.

Link to a notebook

The simplest way to link to a Jupyter Notebook which is stored in the Drive of a collab is to use the URL of the Lab link in the navigation menu of that collab. That link opens JupyterLab with its file browser focused on the appropriate Drive folder but it does not open any specific Notebook.

Example: https://wiki.ebrains.eu/bin/view/Collabs/my-collab-name/Lab

Users can determine a direct link that will open the Jupyter Notebook by following these steps:

  1. Open JupyterLab
  2. Right-click on the Notebook file in the file browser of JupyterLab and select Copy Shareable Link
  3. Edit the URL to:
    1. remove anything before the last https:// (in cases where the URL has more than one)
    2. replace the /user/username/ by /user-redirect/ (note there is one fewer slash '/')
    3. you should not have spaces in the URL, they appear as %20 or as a dash '-'

The resulting URL should look like:

https://lab.ebrains.eu/user-redirect/lab/tree/drive/Shared%20with%20groups/my-collab-name/my-notebook-file.ipynb

Embed a notebook viewer in a wiki page

Export a snapshot of a notebook as an HTML file

Go to https://lab.ebrains.eu , choose a notebook, optionally run it, and then export the notebook as HTML.
 

lab_export_html.png

Upload the HTML file as wiki attachment

Go to the wiki page where to embed the notebook viewer. Before editing the wiki page, attach the HTML file generated above in the Attachment section at the bottom of the wiki page. Upload the HTML file. Remember the HTML filename as you will need it for the next step.
 

upload_notebookviewer.png


Insert a "Jupyter Notebook Viewer" macro in a wiki page

Edit your wiki page (the one with the HTML attachment). Select a place in the wiki page where to add the notebook viewer. Click the cog icon to add a macro and select the "Jupyter Notebook Viewer" macro from the macro select dialog and click select.
In the "Filename" field, enter the name of the HTML file you have uploaded in the previous step. In our example this is "hello_collab.html". Under revision, enter the revision of the attachment you want to use. In most cases using the default value will be ok. The revision number is the number that appears on the right of the uploaded filename in the attachment section. In our example above, the revision was the default 1.1 (see figure above).
In the "Height" field, specify the container height in pixels. Default is 500. If content overflows the browser displays vertical scrollbar.

Click the submit button.

jupyter_nbviewer_macro.png

Save and view the wiki page. You should now see the saved snapshot of your notebook in your wiki page. In our example, it will look something like this.