JuliaPluto/PlutoSliderServer.jl

Notebook on binder not editable

jbrea opened this issue · 8 comments

jbrea commented

When I want to run e.g. this notebook on binder (clicking the "run on binder" button in the notebook), it loads fine on binder, but I cannot edit the notebook, unless I navigate to the Pluto main page (by clicking on the Pluto logo at the top), shut down the notebook (clicking the "x" button) and restart it again (clicking on the file name). What does go wrong here? Note that I am using the custom binder url Export_binder_url = "https://mybinder.org/v2/gh/jbrea/MLCourse/binder". Opening the notebook directly on binder through this link works fine.

fonsp commented

There is probably an error in the JS console in the chrome devtools.

Not sure if this caused the issue, but you should version-pin the binder URL, because the pluto version used in binder needs to exactly match the version used to generate the HTML. (You can also leave it empty to use our shared binder repository, which is always version-matched automatically.)

jbrea commented

Thanks for the feedback.

I do indeed get an error message in the console, but I have difficulties interpreting it.

js_console_error

I don't think the version is a problem. I use a custom docker image on binder that uses the same manifest file as the one that is used by the sliderserver.

I also tried Export_binder_url = "https://mybinder.org/v2/gh/jbrea/MLCourse/binder?urlpath=pluto/open?path%3D/home/jovyan/MLCourse/notebooks/" but it looks like the string after the question mark is ignored.

fonsp commented

Thanks so much for this report @jbrea !

This turned out to be a bug in Pluto's frontend, probably caused by my recent rewrite of the binder backend (fonsp/Pluto.jl#2029). The problem occurred when both a sliderserver URL and a binder URL were set, I forgot to test this combination...

Fix is here: fonsp/Pluto.jl#2043 . I tested this on your combination of statefile, notebook, sliderserver and binder URL and it works!

Schermafbeelding 2022-04-20 om 23 06 20

fonsp commented

You should restore the setting

Export_binder_url = "https://mybinder.org/v2/gh/jbrea/MLCourse/binder?urlpath=pluto/open?path%3D/home/jovyan/MLCourse/notebooks/"

to the original:

Export_binder_url = "https://mybinder.org/v2/gh/jbrea/MLCourse/binder"

This URL should point to the root, e.g.

"https://mybinder.org/v2/gh/fonsp/pluto-on-binder/v0.19.0"

and our client will use this as starting point for binder's REST API, e.g. by adding ?urlpath=pluto/....

fonsp commented

I also recommend setting Export_baked_statefile = false, this will slightly improve loading times and show a loading bar.

fonsp commented

Also some extra context: The two 404 errors in your screenshot are "expected", they both have fallbacks.

You can ignore the binder_token_please request, this is just a bonus feature if it works.

The /open?path=... request might be interesting to understand. Here is how we connect to binder in the background, then start running the notebook on that server, then connect to the running notebook:

https://github.com/fonsp/Pluto.jl/blob/v0.19.0/frontend/common/Binder.js

In particular, this is where we make HTTP requests to Pluto's server to launch the notebook: https://github.com/fonsp/Pluto.jl/blob/90d71f86c013281a51fb642ae82403a3d3231a91/frontend/common/Binder.js#L128-L142 We first try to open a notebook file with the same name on the binder server (e.g. model_evaluation.jl), and if that doesn't work, we ask the server to download the notebook file using its full URL (e.g. https://bio322.epfl.ch/notebooks/model_evaluation.jl).

This first method, using the notebook filename, almost never works, because most people use https://github.com/fonsp/pluto-on-binder/ (which does not have your notebooks locally), and because the path is dropped, only the filename is used. This is old code that could definitely be improved!

jbrea commented

Fantastic. Now it works. Thanks a lot!

ps. I also tried Export_baked_state = false, but with this setting the html files on bio322.epfl.ch showed up as empty white pages. I didn't explore why this happened and went back to the default.

pps. Is it possible to customise the text that is shown when clicking the edit or run this notebook button? With your fix, clicking on binder works as expected, but simply downloading the file to disk and following the standard instructions does not work, unless MLCourse is already available in julia's dev folder. Therefore I would like to customise the download instructions and tell the user to run additionally using Pkg; Pkg.activate(temp = true); Pkg.develop(url = "https://github.com/jbrea/MLCourse").

fonsp commented

Thanks for the suggestion! Right now this is not possible, so I made fonsp/Pluto.jl#2064