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
pm.sample with no luck.
Specifically it’s the output messages printed out about NUTS initialising and chains being setup.
Any help - super appreciated.
First you have to disable the progress bar, using
progressbar = False.
Then disable the pymc3 logs using,
logger = logging.getLogger("pymc3")
logger.propagate = False
Awesome thanks @Nadheesh!!
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??
In my project using python 3.6 or 3.7 this works:
logger = logging.getLogger('pymc3')
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).
Seems like this could be a decent use for a context manager. You could implement it yourself or contribute it perhaps. Something like:
trace = pymc3.trace()
None of the mentioned ways work for me. I am using python 3.9. Any idea how to solve this issue?
I’ve not used this method in a long time (5 years!) so YMMV, but you could try simply catching the output and redirecting it.
e.g here I dump to a string:
from contextlib import redirect_stdout
f = io.StringIO()
with pm.Model as mdl: