New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn off tqdm from application code #619
Comments
before importing the offending package you could do something like: import tqdm
def nop(it, *a, **k):
return it
tqdm.tqdm = nop |
That would work but it's not very robust since it depends on the order of imports. It'd be fine if I was doing a one-off script for example where I have absolute control of how I import things but if I monkey patch
Above would work, but if a user switches the imports it won't work An alternative to an env var is to have a module-level variable that we can toggle from application code like # tqdm land
enabled = True
def disable():
global enabled
enabled = False
# user land
import tqdm
tqdm.disable() |
Any updates on this? Seems very useful when I use this in Jupyter notebooks and want to sometimes disable progress bars globally. |
I think the main discussion is #614 |
Closing this in favour of #614 |
Summary: This allows tqdm to be turned off, by passing a flag through `infer()` to `_infer()`. I chose this approach of passing through the hierarchy because it should fare well in the future growth of BeanMachine's UX, where the `bool` should probably be replaced with several levels/layers of `verbose`, which might be set/modified at various layers of the inheritance hierarchy. Conversely, this design might be too clunky/bloated because it passes through several layers of wrappers. Please let me know! An alternative approach could be to use some global variable. These are viable suggestions for this approach: tqdm/tqdm#619, tqdm/tqdm#612 Reviewed By: nazanint Differential Revision: D20741860 fbshipit-source-id: 73fbb5fa0543cf8331f6417f175442c482db9246
For those still stumbling upon this problem, perhaps this might be useful, as an improvement of @casperdcl's solutions:
This has almost the identical effect as the This can also be further customised to not override the library parameter settings, but only change tqdm's default behaviour, by replacing the line |
Thank you very much! This is exactly what I needed. |
@kaivalyar I added these lines to my code - nothing happened - tqdm still shows progress bars. |
Thanks everyone for your patience! Just released |
read the [known issues]
environment, where applicable:
I'm using a package that uses
tqdm
internally and I'd like to disable tqdm from within application code.#612 would've been ideal. It was closed because the solution solved the problem for the author of the issue but not for us since we cannot modify library code. Thanks.
The text was updated successfully, but these errors were encountered: