Hub Python Library documentation

Repo-specific helper methods

You are viewing v0.5.1 version. A newer version v0.26.2 is available.
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

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.

huggingface_hub.utils.logging.get_verbosity

< >

( )

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

< >

( verbosity: int )

Parameters

  • verbosity (int) — Logging level, e.g., huggingface_hub.logging.DEBUG and huggingface_hub.logging.INFO.

Sets the level for the HuggingFace Hub’s root logger.

huggingface_hub.utils.logging.set_verbosity_info

< >

( )

Sets the verbosity to logging.INFO.

huggingface_hub.utils.logging.set_verbosity_debug

< >

( )

Sets the verbosity to logging.DEBUG.

huggingface_hub.utils.logging.set_verbosity_warning

< >

( )

Sets the verbosity to logging.WARNING.

huggingface_hub.utils.logging.set_verbosity_error

< >

( )

Sets the verbosity to logging.ERROR.

huggingface_hub.utils.logging.disable_propagation

< >

( )

Disable propagation of the library log outputs. Note that log propagation is disabled by default.

huggingface_hub.utils.logging.enable_propagation

< >

( )

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

< >

( name: typing.Optional[str] = None )

Parameters

  • name (str, optional) — The name of the logger to get, usually the filename

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()