jupyter-sphinx icon indicating copy to clipboard operation
jupyter-sphinx copied to clipboard

Option to suppress log stderr warnings

Open SeanDS opened this issue 4 years ago • 5 comments
trafficstars

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...

SeanDS avatar Apr 14 '21 14:04 SeanDS

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

akhmerov avatar Apr 20 '21 07:04 akhmerov

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

SeanDS avatar Apr 20 '21 07:04 SeanDS

IIRC we have a separate flag for execution errors.

akhmerov avatar Apr 20 '21 07:04 akhmerov

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!

SeanDS avatar Apr 20 '21 07:04 SeanDS

Indeed, this docstring is clearly incorrect.

akhmerov avatar Apr 20 '21 10:04 akhmerov