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

Disable tqdm progress bar if no TTY attached #2000

Merged
merged 2 commits into from
Jan 25, 2024
Merged

Disable tqdm progress bar if no TTY attached #2000

merged 2 commits into from
Jan 25, 2024

Conversation

mssalvatore
Copy link
Contributor

When dockerized applications write to STDOUT/STDERR, the applications can block due to logging back pressure (see
https://docs.docker.com/config/containers/logging/configure/#configure-the-delivery-mode-of-log-messages-from-container-to-log-driver6

HuggingFace's TGI container is one such example (see huggingface/text-generation-inference#1186).

Setting tqdm's disable=None will disable the progress bar if no tty is attached and help to resolve TGI's issue #1186.

References:
huggingface/text-generation-inference#1186 (comment)
huggingface/text-generation-inference#1186 (comment)

@Wauplin
Copy link
Contributor

Wauplin commented Jan 25, 2024

Hi @mssalvatore, thanks for investigating this issue! Just to be sure, the solution for TGI would be to disable progress bars when downloading? For what I understand the PR simply change that if logger.getEffectiveLevel() != logging.NOTSET then the disable value is set to None instead of False. Is that the expected fix?

For your info, disabling progress bars can be done by setting HF_HUB_DISABLE_PROGRESS_BARS=1 as an environment variable. Maybe that could be a temporary fix for you before figuring out at which level we want to fix this (I'm still not so sure if this is a huggingface_hub bug).

pinging @OlivierDehaene @Narsil who maintain TGI

@mssalvatore
Copy link
Contributor Author

@Wauplin, yes, that's the intended fix. It preserves the current behavior which is that the progress bar is disabled if logger.getEffectiveLevel() != logging.NOTSET. When the disable value is set to None, the bar is disabled if no TTY is attached. I'll give HF_HUB_DISABLE_PROGRESS_BARS a try and see if it resolves the issue.

Regarding whether or not huggingface_hub should accept this patch: is there a reason you would ever want the progress bar to be enabled if no TTY were attached?

@Wauplin
Copy link
Contributor

Wauplin commented Jan 25, 2024

TIL from tqdm's docs:

image

So yes, definitely agree with this PR! I wasn't aware of the nuance between None and False is this particular case. Thanks for noticing!

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mssalvatore for finding out about this and opening this PR! The change looks good to me now (didn't know about this default behavior before). Could you also update the tqdm in lfs.py as well (same fix + same comment). Thanks in advance!

src/huggingface_hub/file_download.py Show resolved Hide resolved
When dockerized applications write to STDOUT/STDERR, the applications
can block due to logging back pressure (see
https://docs.docker.com/config/containers/logging/configure/#configure-the-delivery-mode-of-log-messages-from-container-to-log-driver6

HuggingFace's TGI container is one such example (see huggingface/text-generation-inference#1186).

Setting tqdm's `disable=None` will disable the progress bar if no tty is
attached and help to resolve TGI's issue #1186.

References:
    huggingface/text-generation-inference#1186 (comment)
    huggingface/text-generation-inference#1186 (comment)
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes @mssalvatore ! Failed tests in CI are unrelated so let's get it merge :)

@Wauplin Wauplin merged commit c85f3ee into huggingface:main Jan 25, 2024
11 of 14 checks passed
@mssalvatore mssalvatore deleted the fix-tgi-1186 branch January 25, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants