Stop all output messages to console


#1

Hey All

I was just wondering is there any way to stop all of the output, to the console, that comes from pymc3? I’ve turned off progressbar and tried verbose=0 and verbose=False in pm.model and pm.sample with no luck.

Specifically it’s the output messages printed out about NUTS initialising and chains being setup.

Any help - super appreciated.

Thanks.


#2

First you have to disable the progress bar, using progressbar = False.

Then disable the pymc3 logs using,

import logging
logger = logging.getLogger("pymc3")
logger.propagate = False

#3

Awesome thanks @Nadheesh!!


#4

Hi, this does not work. Python 3.6, pymc3 3.5

I still get the messages about “Auto-assigning NUTS sampler…” “Initializing NUTS using …” etc. I did exactly as you said with the logging and setting propagate to false. Nope. It’s still getting printed.

Why is there an option to turn off the progress bar – which does work perfectly – but no option to turn off the other messages??? That is silly.

Do I need to open an issue on github? Or has something else changed since May that makes the propagate=False on logging no longer work??

Very annoying.

@Nadheesh


#5

In my project using python 3.6 or 3.7 this works:

import logging
logger = logging.getLogger('pymc3')
logger.setLevel(logging.ERROR)

#6

@SamChill

Yes! That worked. Naturally, of course, you still have to use progressbar=False in order to suppress just that part of it. But at least the combination of using your logging code and setting the pb arg works.

Still silly that there isn’t a simply switch to either set all verbosity to zero or two switches (one for pb and one for other messages).

Thank you!


#7

Seems like this could be a decent use for a context manager. You could implement it yourself or contribute it perhaps. Something like:

with pymc3.disableLogs():
    trace = pymc3.trace()