internal.disableTensorflowLogging

A module you can import that does one thing: It makes Tensorflow shut up.

You can import this before you import tensorflow in your code, and some of the warning messages will go away.

There is also a class (with context manager support) for capturing ALL stderr messages. Use with caution since it can delete important errors!

class bpreveal.internal.disableTensorflowLogging.LeaveStderrAlone

Don’t redirect stderr. Can still be used as a context manager.

This is mostly meant to be used as a dummy when the user has chosen not to suppress stderr.

class bpreveal.internal.disableTensorflowLogging.SuppressStderr

Used with a context manager, this will redirect stderr.

When the context manager leaves, this object will have a string called output that contains all of the garbage that was sent to stderr.

Note that this will globally redirect stderr, so any logging messages will be unceremoniously deleted. Use this class with caution!

The code for this class is taken from the stream_redirection code in benchopt. Benchopt is licensed under the BSD 3-clause license, which is included in BPReveal in etc/benchopt_license.txt.