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

Allow to turn off tqdm via environment variables #612

Closed
2 tasks done
faroit opened this issue Sep 16, 2018 · 5 comments · Fixed by #1491
Closed
2 tasks done

Allow to turn off tqdm via environment variables #612

faroit opened this issue Sep 16, 2018 · 5 comments · Fixed by #1491
Assignees
Labels
c3-small 🕒 Complexity medium duplicate 🗐 Seen it before p2-bug-warning ⚠ Visual output bad p3-enhancement 🔥 Much new such feature question/docs ‽ Documentation clarification candidate
Projects

Comments

@faroit
Copy link

faroit commented Sep 16, 2018

often I use the same code on my local dev machine and a cluster node. To not mess up the log files I normally turn off tqdm. While this is a simple change in the python code, I think it would actually be more convenient to let tqdm check for environment variables and thereby add some level of system level control over tqdm.

e.g. TQDM=disabled python run.py could quickly disable tqdm in any script.
This should be easy to implement using os.environ.get(). I can compile a PR if you like this proposal

  • I have visited the [source website], and in particular
    read the [known issues]
  • I have searched through the [issue tracker] for duplicates
@faroit faroit changed the title Allow to turn of tqdm via environment variables Allow to turn off tqdm via environment variables Sep 16, 2018
@casperdcl
Copy link
Sponsor Member

casperdcl commented Sep 17, 2018

why not use

from tqdm import tqdm
import os

for x in tqdm(..., disable=os.environ.get("DISABLE_TQDM", False)):
    ...

@faroit
Copy link
Author

faroit commented Sep 18, 2018

thats a quick solution, thanks. I would still like the suggestions in #614

@faroit faroit closed this as completed Sep 18, 2018
@casperdcl casperdcl self-assigned this Sep 19, 2018
@casperdcl casperdcl added the question/docs ‽ Documentation clarification candidate label Sep 19, 2018
facebook-github-bot pushed a commit to facebookresearch/beanmachine that referenced this issue Apr 9, 2020
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
casperdcl added a commit that referenced this issue Aug 5, 2023
- fixes #370, fixes #612, fixes #619, fixes #1318
- closes #950, closes #1061
casperdcl added a commit that referenced this issue Aug 8, 2023
- fixes #370, fixes #612, fixes #619, fixes #1318
- closes #950, closes #1061
casperdcl added a commit that referenced this issue Aug 8, 2023
- fixes #370, fixes #612, fixes #619, fixes #1318
- closes #950, closes #1061
@casperdcl casperdcl added duplicate 🗐 Seen it before p3-enhancement 🔥 Much new such feature p2-bug-warning ⚠ Visual output bad c3-small 🕒 Complexity medium labels Aug 9, 2023
@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 :)

@jamesbraza
Copy link

For those coming across this issue, the tl;dr on env var overrides (e.g. TQDM_MININTERVAL) works is:

  1. env var override support #1491 added utils.envwrap, which decorates functions to pull keyword argument overrides from the environment variables matching a prefix (docs)
  2. envwrap decorates the main tqdm with the prefix TQDM_ (amongst other places): https://github.com/tqdm/tqdm/blob/v4.66.2/tqdm/std.py#L951-L960

So to apply this knowledge:

  1. Go to the docs for tqdm
  2. Look up the desired argument name (e.g. mininterval, disable)
  3. Match a keyword argument to your environment variable (e.g. mininterval --> TQDM_MININTERVAL)

@timeleft--
Copy link

And just to be clear: TQDM_DISABLE=1 does disable TQDM like the issue author originally requested.

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 p2-bug-warning ⚠ Visual output bad p3-enhancement 🔥 Much new such feature question/docs ‽ Documentation clarification candidate
Projects
Casper
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants