Skip to content
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

Set tqdm.disable from os.environ #1061

Closed
wants to merge 1 commit into from

Conversation

Grokzen
Copy link

@Grokzen Grokzen commented Oct 27, 2020

This PR is a updated version of #950 that also adds in tests and updates the documentation for the disable parameter, and it updates the branch to be able to merge again as the other PR is stale since before the summer.

The following is taken from #950

Allow setting the tqdm.disable option from the environment variables.
The default value of False is unchanged, as is the expected behavior with None.

Resolves issues laid out it #619 #614 #612. Similar to the request in #370.

We evaluated the following suggestion that was posted earlier and decided it was not good enough as a general solution as it would both require us to update all usages of tqdm in our code, and we would have to remove it when/if this PR would be added in and all developers coding new code that uses tqdm would have to remember/know that they need to add in that fix in order to get the centralized disable feature.

from tqdm import tqdm
import os

for x in tqdm(..., disable=os.environ.get("DISABLE_TQDM", False)):
    ...
  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
    • documentation request (i.e. "X is missing from the documentation." If instead I want to ask "how to use X?" I understand StackOverflow#tqdm is more appropriate)
    • new feature request
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and

environment, where applicable:

>>> import tqdm, sys
>>> print(tqdm.__version__, sys.version, sys.platform)
4.51.0-git.UNKNOWN 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0] linux

Usecase example

A simple use-case for this option is that we are running a big set of code where we have both support to run the exact same code as a cli tool from a users computer and in a hosted environment inside celery. And when we run it in celery, we do not want our logs to be polluted with tdqm loggin output. This option would make it super easy to disable all tdqm logging as we have it in a lot of places in our code and we would just configure our production servers with ansible/terraform to have this environment variable and we are all set and can controll our logging from a central point.

@Grokzen
Copy link
Author

Grokzen commented Oct 28, 2020

I can't restart the failed job and you have to look into why it fails out with the SSL problem, it is not really related to this PR from what i see.

@casperdcl casperdcl force-pushed the devel branch 2 times, most recently from d6430db to d13dfbf Compare August 5, 2023 22:10
casperdcl added a commit that referenced this pull request Aug 5, 2023
- fixes #370, fixes #612, fixes #619, fixes #1318
- closes #950, closes #1061
casperdcl added a commit that referenced this pull request Aug 8, 2023
- fixes #370, fixes #612, fixes #619, fixes #1318
- closes #950, closes #1061
casperdcl added a commit that referenced this pull request Aug 8, 2023
- fixes #370, fixes #612, fixes #619, fixes #1318
- closes #950, closes #1061
@casperdcl
Copy link
Sponsor Member

Thanks for your patience! Just released tqdm==4.66.0 which includes support for env var overrides. I'm using TQDM_MININTERVAL=5 in most of my CI jobs now :)

@casperdcl casperdcl self-assigned this Aug 9, 2023
@casperdcl casperdcl added duplicate 🗐 Seen it before p3-enhancement 🔥 Much new such feature c3-small 🕒 Complexity medium labels Aug 9, 2023
@casperdcl casperdcl added this to Done in Casper Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c3-small 🕒 Complexity medium duplicate 🗐 Seen it before p3-enhancement 🔥 Much new such feature
Projects
Casper
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants