pymc-devs / pymc

Bayesian Modeling and Probabilistic Programming in Python
https://docs.pymc.io/
Other
8.67k stars 2k forks source link

ENH: Disable all progress bars #7151

Open JakeSummers opened 7 months ago

JakeSummers commented 7 months ago

Context for the issue:

Currently the progress bars printed by pymc are printed to stdout in my backend service. They often corrupt the structured logs that my service prints.

Right now, I need to go through my code to disable all of the progress bars.

Aka I need to, update from:

pm.sample(samples, random_seed=random_seed)

To:

pm.sample(samples, random_seed=random_seed, progressbar=False)

It would make my code better, if I could do something like:

pm.progress_bar(False)

And that would disable all progress bars in pymc.

This would allow me to make my code easy to use with the backend service we integrate with but also to use in notebooks or IDEs.

Related: https://github.com/fastai/fastprogress/issues/105

welcome[bot] commented 7 months ago

Welcome Banner] :tada: Welcome to PyMC! :tada: We're really excited to have your input into the project! :sparkling_heart:
If you haven't done so already, please make sure you check out our Contributing Guidelines and Code of Conduct.

JakeSummers commented 7 months ago

Workaround from: https://github.com/fastai/fastprogress/issues/105#issuecomment-1939645396

It looks like this is possible like this:

import fastprogress.fastprogress
fastprogress.fastprogress.NO_BAR = True

If you also want to disable the output from master_bar.write, you can do this:

def do_nothing(*args):
    pass

fastprogress.fastprogress.WRITER_FN = do_nothing

I wonder if this should be added to pymc's api so that if/when the fastprogress dependency is switched for something else, that we will keep the same structure.

ricardoV94 commented 7 months ago

Not counting on switching that dependency anytime soon