h2o-llmstudio icon indicating copy to clipboard operation
h2o-llmstudio copied to clipboard

[CODE IMPROVEMENT] Redirect stdout logging from huggingface download to the logging module

Open pascal-pfeiffer opened this issue 2 years ago • 2 comments
trafficstars

🔧 Proposed code refactoring

Redirect stdout logging from huggingface download to the logging module

Something on these line could solve it (untested):

import logging
from transformers import logging as transformers_logging

logger = logging.getLogger(__name__)
transformers_logging.set_verbosity_info()
transformers_logging.enable_default_handler()

# Redirect the download progress bar to the logger
transformers_logging.install_verbosity_handler(logger=logger, log_level=logging.INFO)

# Now, any download done by Hugging Face will be logged to the logger

Motivation

Improve logs that are shown in the web app

pascal-pfeiffer avatar May 03 '23 19:05 pascal-pfeiffer

Like the idea! Tricky part may be progress bars (model downloads etc.) that could cause logging a new line at each update.

maxjeblick avatar May 03 '23 19:05 maxjeblick

I am in the same situation than @pascal-pfeiffer, I need to redirect the tf_logging more specifically the progressbar for downloading models to other streams, e.g., the logging module. Is there a workaround?

aress31 avatar May 06 '23 10:05 aress31