From d586125b407f2a6d3502c8d399db333aeeb3731b Mon Sep 17 00:00:00 2001 From: fatalis Date: Wed, 24 Jun 2026 08:55:38 -0500 Subject: [PATCH] Force HF downloads to show progress bars when output is not a TTY (#909) --- toolkit/__init__.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/toolkit/__init__.py b/toolkit/__init__.py index e69de29..5ae76ce 100644 --- a/toolkit/__init__.py +++ b/toolkit/__init__.py @@ -0,0 +1,24 @@ +import importlib +import logging + + +def force_hf_hub_progress_bars(): + hf_tqdm = importlib.import_module('huggingface_hub.utils.tqdm') + + original_is_tqdm_disabled = hf_tqdm.is_tqdm_disabled + if getattr(original_is_tqdm_disabled, '_aitk_forced_progress', False): + return + + def is_tqdm_disabled(log_level): + disabled = original_is_tqdm_disabled(log_level) + # UI jobs log to files, so stderr is not a TTY. Keep HF download bars + # visible while preserving normal carriage-return progress updates. + if disabled is None and log_level != logging.NOTSET: + return False + return disabled + + is_tqdm_disabled._aitk_forced_progress = True + hf_tqdm.is_tqdm_disabled = is_tqdm_disabled + + +force_hf_hub_progress_bars()