thebe icon indicating copy to clipboard operation
thebe copied to clipboard

Option to "Run All"

Open chrisjsewell opened this issue 3 years ago • 11 comments

Executing the whole notebook first is obviously a common task, followed by re-executing certain cells with modification (and here #493 would then also be helpful)

chrisjsewell avatar Oct 03 '21 21:10 chrisjsewell

Thanks for the comment @chrisjsewell. So calling thebelab.restartAndRunAll() once there is a kernel available will trigger a run of all the cells on the page.

Currently, this is accessible to the user (if not hidden in CSS by the consumer) via the "Restart & Run All" button appended to each cell. Which of course also restarts.

So the executing the notebook first, or providing a Run All button, seems like a choice for the downstream page/code to implement.

What we could do here is (1) add an example to the docs (2) add this option to the Kernel Status widget that was recently added, but not all downstream apps/pages use that (3) potentially separate the Restart and Run All steps, so that Run All can be carried out without the kernel restart [but does that make sense?]

In fact, @chrisjsewell if this is in the context of a jupyter-book using thebe, then sphinx-thebe is maybe the right place to be making the change? the "status" widget implemented in there is the one used in jupyter-book builds unless I'm mistaken. e.g. extending https://github.com/executablebooks/sphinx-thebe/blob/master/sphinx_thebe/_static/sphinx-thebe.js to include a Run All button.

Is this what you had in mind? if not please provide a bit more context.

stevejpurves avatar Oct 04 '21 13:10 stevejpurves

Heya, yeh I haven't looked into what the responsibilities are between thebe and sphinx-thebe, but basically with https://sqla-tutorials-nb.readthedocs.io/en/latest/engine.html, I get:

image

So here, I feel there are at least three things missing:

  1. The ability to run all calls
  2. An indication of what cells have actually been executed (and what ones are just showing the original outputs)
  3. An indication of in what order the cells have been executed

Hence this issue and #493

(Also showing the log as the binder is building/launching would be nice, to know things are happening, which I recall you already mentioning)

chrisjsewell avatar Oct 04 '21 14:10 chrisjsewell

Actually, maybe instead of (or in addition to) running all cells, there would be the option to run all cells up-to a certain cell, i.e. the Run All Above option in the Notebook interface:

image

If you want to see the output from a certain cell, it will often be the case that it requires all the preceding cells having been executed.

chrisjsewell avatar Oct 04 '21 14:10 chrisjsewell

yeah, ok. I just caught up with you

image

We can do something on this for sure -- between here and sphinx-thebe 👍

stevejpurves avatar Oct 04 '21 20:10 stevejpurves

Hi, was this feature ever implemented? I'd love to have a Run All button available for a Jupyter Book I'm creating but I'm not sure how to enable this / how to use sphinx-thebe to do it.

rsenft1 avatar Mar 22 '22 21:03 rsenft1

There is a "restart and run all" button that is enabled by default in the latest versions of thebe.

moorepants avatar Mar 23 '22 05:03 moorepants

Alternatively if you are able to add a button yourself in javascript, then making this call will execute all the cells without the kernel restart. window.thebe.cells.map((idx, { execute }) => execute());. Here's that line in context https://github.com/executablebooks/thebe/blob/15930c15f0f21ed17993e13a1aabbc16b73ae916/src/render.js#L200

It would be good to have the run all button by default in sphinx-thebe though - we will do that - probably add a button on / around the kernel status display?

in the meantime as @moorepants points out, hitting the restart and rul all button on the first cell is the closest image

stevejpurves avatar Mar 23 '22 11:03 stevejpurves

This enhancement is best tracked here: https://github.com/executablebooks/sphinx-thebe/issues/50

stevejpurves avatar Mar 23 '22 11:03 stevejpurves

There is a "restart and run all" button that is enabled by default in the latest versions of thebe.

Yes I can see that on the docs website as well. My issue is that when I try making a Jupyter Book with thebe enabled for live coding, I can't seem to figure out how to get this button (I just see Run and Restart). I've tried downloading thebe doc pages as markdown or rst and then building the jupyter book but so far I haven't been able to figure out why this button isn't appearing. In my test book, thebe is enabled under launch_buttons. Do you know if there is something specific about Jupyter Book that overrides this button? Or maybe somewhere where I need to point to a javascript resource?

rsenft1 avatar Mar 23 '22 13:03 rsenft1

It sounds like you might be pointing to an older thebe version in your configuration.

moorepants avatar Mar 23 '22 14:03 moorepants

Do you know if there is something specific about Jupyter Book that overrides this button? Or maybe somewhere where I need to point to a javascript resource?

That's probably a question for the jupyter book devs. Maybe ask over on that repo.

moorepants avatar Mar 23 '22 14:03 moorepants