executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx

Home Page:https://myst-nb.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add configuration option to elevate warnings during notebook execution to exceptions.

rossbar opened this issue · comments

Context

I'm looking for a way to control the behavior of warnings that are raised during notebook execution. Specifically, I want to escalate all warnings to exceptions i.e. something like a default warnings.filterwarnings("error") for all notebooks. I can achieve this behavior now by adding this filter to each notebook individually, but it'd be great to be able to control this via configuration rather than within the code itself for each notebook.

My naive attempt was to specify the warnings filter(s) in conf.py which is a common practice for catching errors in docstring examples, but the filtering does not extend to warnings raised during notebook execution.

Proposal

Some way to control the warnings behavior during notebook execution. As mentioned this is already possible at the notebook level by specifying the warnings filters in {code-cell}s, but this has drawbacks:

  1. having to be added to each notebook individually and
  2. being visible in the Jupyter notebook (though it can be hidden in html output via the tags).

Tasks and updates

No response