executablebooks / jupyter-book

Create beautiful, publication-quality books and documents from computational content.
http://jupyterbook.org
BSD 3-Clause "New" or "Revised" License
3.75k stars 652 forks source link

Set nb_execution_raise_on_error from JupyterBook config #2011

Open brian-rose opened 1 year ago

brian-rose commented 1 year ago

Context

Currently it seems that if we set in the _config.yml file:

execute:
    allow_errors: False

then notebook execution will halt when a notebook cell raises an exception. However the jupyter-book build process will still complete.

I'm interested in the use case where we want jupyter-book build to report failure if there are any exceptions raised during notebook execution, rather than just giving warnings. The context is for the regular CI testing of notebook-based content for Project Pythia Cookbooks.

It seems like myst-nb has the appropriate config option nb_execution_raise_on_error, e.g. in the docs here. But I don't see any way to pass this flag to myst-nb from jupyter-book.

I'm looking at this code where the mapping between jupyter-book config keys and sphinx keys is set, and there is no mention of the nb_execution_raise_on_error option.

Maybe this has just not yet been implemented?

Proposal

Add an option to the JupyterBook configuration like

execute:
    raise_on_error: false

(default to false to match the default value in myst-nb)

Pass this on to sphinx and myst-nb so the user has the option of allowing jupyter-book build to fail when a notebook raises an exception by setting raise_on_error: true in the JupyterBook config file.

If this is a sensible approach, I'm happy to work on PR to implement this. But it's also very possible that this functionality exists and I'm just missing something, in which case I'm happy to work on some improvements to documentation.

Tasks and updates

No response

joamatab commented 1 year ago

yes, there is an issue for that

https://github.com/executablebooks/jupyter-book/issues/1691

a PR would be great

https://github.com/gdsfactory/gdsfactory/issues/1482

brian-rose commented 1 year ago

I found a simple workaround, which is to put the following in the _config.yml file:

sphinx:
  config:
    nb_execution_raise_on_error: true