Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to "Run All" #494

Open
chrisjsewell opened this issue Oct 3, 2021 · 11 comments
Open

Option to "Run All" #494

chrisjsewell opened this issue Oct 3, 2021 · 11 comments

Comments

@chrisjsewell
Copy link

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)

@stevejpurves
Copy link
Collaborator

stevejpurves commented Oct 4, 2021

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.

@chrisjsewell
Copy link
Author

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
Copy link
Author

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.

@stevejpurves
Copy link
Collaborator

yeah, ok. I just caught up with you

image

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

@rsenft1
Copy link

rsenft1 commented Mar 22, 2022

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.

@moorepants
Copy link
Collaborator

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

@stevejpurves
Copy link
Collaborator

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
Copy link
Collaborator

This enhancement is best tracked here: executablebooks/sphinx-thebe#50

@rsenft1
Copy link

rsenft1 commented Mar 23, 2022

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?

@moorepants
Copy link
Collaborator

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

@moorepants
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants