jupyter / jupyter-sphinx

Sphinx extension for rendering of Jupyter interactive widgets.
https://jupyter-sphinx.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
187 stars 65 forks source link

Option to suppress log stderr warnings #178

Open SeanDS opened 3 years ago

SeanDS commented 3 years ago

I have a cell that emits a log warning, which the default log handler then directs to stderr. This gives a warning in Sphinx during the build:

WARNING: Cell printed to stderr:
            my.code [ WARNING]: my warning

It would be nice if there were a way to suppress log warnings similar to how one can control exceptions. Perhaps a way to control the minimum log level printed to stderr via an option? e.g.

.. jupyter-execute::
    :log-level: error

    ...my code...
akhmerov commented 3 years ago

Good idea! There's already a flag :stderr:, could we instead extend it with :stderr: ignore?

SeanDS commented 3 years ago

That might be enough, though might that mask real cell errors too?

akhmerov commented 3 years ago

IIRC we have a separate flag for execution errors.

SeanDS commented 3 years ago

It's a bit strange, because the docs say:

Additionally, any output sent to the stderr stream of a cell will result in jupyter-sphinx raising an exception. This behaviour can be suppressed (and the stderr stream printed as regular output) by providing the stderr option:

In my experience, jupyter-sphinx is not raising an exception, just issuing a warning during build when cells write to stderr. Would ignoring stderr actually help here then? I think we actually need a way to ignore or not issue the warning issued by jupyter-sphinx when something gets printed to stderr.

If that's what you meant, then all good!

akhmerov commented 3 years ago

Indeed, this docstring is clearly incorrect.