Hosting interactive pluto notebook on web/Github

Hello. I’m very new to Julia. I did dabble with it about 3 years ago, but only in the last week have I decided to work much more with it. I’m a very long time R user.

I have been working through the pluto.jl examples and find them very useful. I have also created some interactive notebooks of my own. However, whenever I export to static HTML, the files lose interactivity in the browser. e.g. sliders no longer are interactive - such as the slider at the bottom of the mathematics.jl file.

What I would ideally like to do is to host my custom notebooks on the web somewhere for my students to play around with. Is there an easy way of achieving this? and, should I have expected the sliders to have worked even in the static HTML export?

thanks

4 Likes

Welcome!

Pluto interactivity (and Jupyter interactivity, for that matter) requires interacting with a Julia process. So you’re correct that it doesn’t survive the conversion to static HTML.

Last I checked the status was the following: it’s possible with sufficient effort to host a Pluto notebook using a service like Heroku. It’s also part of the long-term roadmap to support a more convenient way to host your Pluto notebooks on the web. (Again, just recapping what I learned when I was asking this question.) You can see some discussion along these lines here. Grain of salt, though; this info might be out of date at this point.

Actually, I see it’s possible to set up Pluto on Binder; check it out here. I’m guessing that’s going to be your best option in the short term, though more knowledgeable people might weigh in on this thread with the latest info.

6 Likes

Thanks very much - I shall look into Binder.

1 Like

The simplest way is to put your notebook online somewhere (github, github gist, your university web page), and then use pluto-on-binder.glitch.me to generate a binder link for that notebook

10 Likes

I like using Jupyter notebooks because github parses them as an HTML document. So it’s great for me to share with others as a “report”. They may not be able to run/update the code (well, unless they checkout the code)… but it does show all the input and output cells.

That’s why I made pluto-on-binder.glitch.me/ !

6 Likes

Hi Fons!
Here a big fan of Pluto, but in a learning curve on Julia/Pluto.
I tried your pluto-on-binder.glitch.me with a very small Pluto notebook example from my GitHub to test notebook shared online. It works!
But, with a more complex (not so complex) Pluto notebook, it gives me an error when Pluto starts running. I think it may be Julia or Pluto versions on Binder, it gives this error when installing the packages:
Any idea? Please, take time on this issue only if it is simple to solve… because you should be kept on track on important Pluto things :smiley:
Ricardo

1 Like

You can run Pluto on binder with a custom package environment by creating an appropriate github repository. I don’t know if it’s the best way to do it, but I have a working setup at https://github.com/UBCECON567/ioplutonotebooks. Here’s an example of it on binder. I created this setup by making some minor changes to https://github.com/pankgeorg/pluto-on-jupyterlab

If you want to modify it, you could:

  1. Clone https://github.com/UBCECON567/ioplutonotebooks
  2. Replace the contents of the notebooks folder with your notebooks (or maybe just delete it and leave your notebooks in a separate place, so that you can update the notebooks without triggering a rebuild of the binder docker image).
  3. Modify the version of Julia in the Dockerfile if you want something other than 1.5.3
  4. Modify the Project.toml and Manifest.toml files. Probably easiest to just delete them and then recreate them by running something like
using Pkg
Pkg.activate("path/to/repo") # modify this
Pkg.add(["Pluto","PlutoUI", "Plots", "Dierckx", "DataFrames", "DataInterpolations"]) #
  1. Then push your changes, and point mybinder.org to your repository.

Compared to adding packages within a notebook, an advantage of this approach is that package installation and precompilation happens only when the docker the image for the repository is built (or rebuilt after each commit), instead of each time a user opens the notebook. It does, however, take quite some time to rebuild the docker image after the repository is updated.

4 Likes

Hi, I’ll try this out! It looks promising, even though I’m not sure I can do it. But, I will definitely try to follow your explanation.
Thank you in advance

@Paul_Schrimpf thanks for your instructions. Your setup looks nice, and faster and cleaner than the Heroku versions I’ve tried. I’ve almost got it working, but not quite. The Jupyter notebook browser shows up, but Pluto doesn’t launch. If you have a minute, would you take a quick look at my repository to help me identify what’s different about mine from yours?

@roualdes I think you just need to add Pluto to the Project.toml and Manifest.toml files.

How silly of me. Doh. This works great. Thanks so much for sharing (and fixing)!

Spent a little bit of time trying to reduce latency with this set up and had some pretty good success. Possible strategies are to use

  • Julia 1.6, just released!
  • jupyter/base-notebook instead of jupyter/scipy-notebook, the base-notebook is a significantly smaller Docker image, but you lose most Python packages
  • GitHub Actions to reduce mybinder.org startup time, possibly at the expense of longer build times (depending on the strategy you choose)
  • PackageCompiler to build a sysimage to reduce Julia startup latency.

Exact details of my setup are in my plutonotebooks repository.

Thanks again to @Paul_Schrimpf for this great setup.

6 Likes

I followed these steps, including adding Pluto and PlutoUI to the Project.toml file, but the Jupyter notebok browser shows up for me as well, not Pluto.

I then tried feeding your Github repo URL to binder (as well as that of @roualdes from the last post), but those don’t work either - I simply see the Jupyter notebooks. Can someone confirm if @Paul_Schrimpf’s method still works?

I think it still works. From the jupyter file browser, there should be a Pluto.jl option under the New menu near the top right.

An alternative would be static html export plus a Pluto SliderServer, like for the MIT course: Introduction to Computational Thinking

2 Likes

So it does, thank you for pointing it out! After starting Pluto.jl, the notebook URL inside the container (in this case /home/jovyan/notebooks/test.jl) has to be entered manually. Is there a way to start Pluto automatically? I thought the “runpluto.sh” file in the repo would do this.

Is it possible to export a static HTML version with all slider combinations precomputed?
I know that this could lead to very big state space if one is not careful, but it would be a very nice way to host a static interactive notebook. Especially if the computations are more on the expensive side.

I would image it as adding a results cache in javascript for the slider state space.

I manually create and share links like

https://mybinder.org/v2/gh/roualdes/plutonotebooks/main?urlpath=pluto/open?path=/home/jovyan/notebooks/beta.jl

and they open directly into Pluto. For instance, this notebook.

1 Like

This is perfect, thank you.

May I ask how you found the URL scheme (?urlpath=pluto/open) to open Pluto directly?