Controlling the logging of huggingface_hub
The huggingface_hub
package exposes a logging
utility to control the logging level of the package itself.
You can import it as such:
from huggingface_hub import logging
Then, you may define the verbosity in order to update the amount of logs you’ll see:
from huggingface_hub import logging
logging.set_verbosity_error()
logging.set_verbosity_warning()
logging.set_verbosity_info()
logging.set_verbosity_debug()
logging.set_verbosity(...)
The levels should be understood as follows:
error
: only show critical logs about usage which may result in an error or unexpected behavior.warning
: show logs that aren’t critical but usage may result in unintended behavior. Additionally, important informative logs may be shown.info
: show most logs, including some verbose logging regarding what is happening under the hood. If something is behaving in an unexpected manner, we recommend switching the verbosity level to this in order to get more information.debug
: show all logs, including some internal logs which may be used to track exactly what’s happening under the hood.
Return the current level for the HuggingFace Hub’s root logger.
HuggingFace Hub has following logging levels:
huggingface_hub.logging.CRITICAL
,huggingface_hub.logging.FATAL
huggingface_hub.logging.ERROR
huggingface_hub.logging.WARNING
,huggingface_hub.logging.WARN
huggingface_hub.logging.INFO
huggingface_hub.logging.DEBUG
huggingface_hub.utils.logging.set_verbosity
< source >( verbosity: int )
Sets the level for the HuggingFace Hub’s root logger.
Sets the verbosity to logging.INFO
.
Sets the verbosity to logging.DEBUG
.
Sets the verbosity to logging.WARNING
.
Sets the verbosity to logging.ERROR
.
Disable propagation of the library log outputs. Note that log propagation is disabled by default.
Enable propagation of the library log outputs. Please disable the HuggingFace Hub’s default handler to prevent double logging if the root logger has been configured.
Repo-specific helper methods
The methods exposed below are relevant when modifying modules from the huggingface_hub
library itself.
Using these shouldn’t be necessary if you use huggingface_hub
and you don’t modify them.
huggingface_hub.utils.logging.get_logger
< source >( name: typing.Optional[str] = None )
Returns a logger with the specified name. This function is not supposed to be directly accessed by library users.
Example Usage:
>>> from huggingface_hub import get_logger
>>> logger = get_logger(__file__)
>>> logger.set_verbosity_info()