Quiet default CLI progress output - #14
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a quiet mode for the console progress observer, which maps internal step names to user-friendly labels and hides specific processing steps unless the verbose flag is enabled. It also adds logic to suppress Hugging Face model download progress bars during model loading. Feedback was provided to improve the implementation of the download progress suppression by using os.environ.setdefault and simplifying the conditional logic to minimize side effects.
| def _suppress_model_download_progress(self) -> None: | ||
| flag = os.environ.get("HF_HUB_DISABLE_PROGRESS_BARS") | ||
| if flag is None: | ||
| os.environ["HF_HUB_DISABLE_PROGRESS_BARS"] = "1" | ||
| explicitly_enabled = False | ||
| else: | ||
| explicitly_enabled = flag.strip().lower() in {"0", "false", "off", "no"} | ||
| if explicitly_enabled: | ||
| return | ||
|
|
||
| try: | ||
| from huggingface_hub.utils import disable_progress_bars | ||
| except ImportError: | ||
| return | ||
| disable_progress_bars() |
There was a problem hiding this comment.
The logic for suppressing Hugging Face download progress bars is effective, but it relies on modifying the global os.environ. While acceptable for a CLI tool, consider using os.environ.setdefault or only setting it if it's not already present to minimize side effects. Additionally, the check for explicitly_enabled could be simplified.
| def _suppress_model_download_progress(self) -> None: | |
| flag = os.environ.get("HF_HUB_DISABLE_PROGRESS_BARS") | |
| if flag is None: | |
| os.environ["HF_HUB_DISABLE_PROGRESS_BARS"] = "1" | |
| explicitly_enabled = False | |
| else: | |
| explicitly_enabled = flag.strip().lower() in {"0", "false", "off", "no"} | |
| if explicitly_enabled: | |
| return | |
| try: | |
| from huggingface_hub.utils import disable_progress_bars | |
| except ImportError: | |
| return | |
| disable_progress_bars() | |
| def _suppress_model_download_progress(self) -> None: | |
| flag = os.environ.get("HF_HUB_DISABLE_PROGRESS_BARS") | |
| if flag is not None and flag.strip().lower() in {"0", "false", "off", "no"}: | |
| return | |
| os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1") | |
| try: | |
| from huggingface_hub.utils import disable_progress_bars | |
| disable_progress_bars() | |
| except ImportError: | |
| pass |
Summary
Test Plan