o
    5ti                     @   s  d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lm	Z	 dd
lm
Z
 ddlmZ ddlmZ ejejej
ejejdZej
Zdd ZdefddZdejfddZd8ddZd8ddZd9dee dejfddZdefddZdeddfdd Zd!d" Zd#d$ Zd%d& Zd'd( Z d8d)d*Z!d8d+d,Z"e  G d-d. d.Z#d/a$G d0d1 d1Z%e% Zde&fd2d3Z'd4d5 Z(d6d7 Z)dS ):z Logging utilities.     N)CRITICAL)DEBUG)ERROR)FATAL)INFO)NOTSET)WARN)WARNING)Optional)auto)debuginfowarningerrorcriticalc               	   C   sH   t dd} | r"| tv rt|  S t d|  ddt   tS )z
    If EVALUATE_VERBOSITY env var is set to one of the valid choices return that as the new default level.
    If it is not - fall back to ``_default_log_level``
    EVALUATE_VERBOSITYNz"Unknown option EVALUATE_VERBOSITY=z, has to be one of: z, )	osgetenv
log_levelslogging	getLoggerr   joinkeys_default_log_level)env_level_str r   J/home/ubuntu/.local/lib/python3.10/site-packages/evaluate/utils/logging.py_get_default_logging_level*   s   r   returnc                   C   s   t dd S )N.r   )__name__splitr   r   r   r   _get_library_name;   s   r"   c                   C   s   t t S N)r   r   r"   r   r   r   r   _get_library_root_logger?   s   r$   c                  C   s   t  } | t  d S r#   )r$   setLevelr   library_root_loggerr   r   r   _configure_library_root_loggerC   s   r(   c                  C   s   t  } | tj d S r#   )r$   r%   r   r   r&   r   r   r   _reset_library_root_loggerI   s   r)   namec                 C   s   | du rt  } t| S )z(Return a logger with the specified name.N)r"   r   r   )r*   r   r   r   
get_loggerN   s   
r+   c                   C   s
   t   S )a  Return the current level for the Hugging Face Evaluate library's root logger.
    Returns:
        Logging level, e.g., `evaluate.logging.DEBUG` and `evaluate.logging.INFO`.

    <Tip>

        Hugging Face Evaluate library has following logging levels:
        - `evaluate.logging.CRITICAL`, `evaluate.logging.FATAL`
        - `evaluate.logging.ERROR`
        - `evaluate.logging.WARNING`, `evaluate.logging.WARN`
        - `evaluate.logging.INFO`
        - `evaluate.logging.DEBUG`

    </Tip>
    )r$   getEffectiveLevelr   r   r   r   get_verbosityU   s   
r-   	verbosityc                 C   s   t  |  dS )zSet the level for the Hugging Face Evaluate library's root logger.
    Args:
        verbosity:
            Logging level, e.g., `evaluate.logging.DEBUG` and `evaluate.logging.INFO`.
    N)r$   r%   )r.   r   r   r   set_verbosityh   s   r/   c                   C      t tS )zSet the level for the Hugging Face Evaluate library's root logger to `INFO`.

    This will display most of the logging information and tqdm bars.

    Shortcut to `evaluate.logging.set_verbosity(evaluate.logging.INFO)`.
    )r/   r   r   r   r   r   set_verbosity_infoq      r1   c                   C   r0   )zSet the level for the Hugging Face Evaluate library's root logger to `WARNING`.

    This will display only the warning and errors logging information and tqdm bars.

    Shortcut to `evaluate.logging.set_verbosity(evaluate.logging.WARNING)`.
    )r/   r	   r   r   r   r   set_verbosity_warning{   r2   r3   c                   C   r0   )zSet the level for the Hugging Face Evaluate library's root logger to `DEBUG`.

    This will display all the logging information and tqdm bars.

    Shortcut to `evaluate.logging.set_verbosity(evaluate.logging.DEBUG)`.
    )r/   r   r   r   r   r   set_verbosity_debug   r2   r4   c                   C   r0   )zSet the level for the Hugging Face Evaluate library's root logger to `ERROR`.

    This will display only the errors logging information and tqdm bars.

    Shortcut to `evaluate.logging.set_verbosity(evaluate.logging.ERROR)`.
    )r/   r   r   r   r   r   set_verbosity_error   r2   r5   c                   C      dt  _dS )zjDisable propagation of the library log outputs.
    Note that log propagation is disabled by default.
    FNr$   	propagater   r   r   r   disable_propagation   s   r9   c                   C   r6   )zEnable propagation of the library log outputs.
    Please disable the Hugging Face Evaluate library's default handler to prevent double logging if the root logger has
    been configured.
    TNr7   r   r   r   r   enable_propagation   s   r:   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )	EmptyTqdmz%Dummy tqdm which doesn't do anything.c                 O   s   |r	|d | _ d S d | _ d S )Nr   )	_iteratorselfargskwargsr   r   r   __init__   s   zEmptyTqdm.__init__c                 C   s
   t | jS r#   )iterr<   r>   r   r   r   __iter__   s   
zEmptyTqdm.__iter__c                 C   s   dd }|S )zReturn empty function.c                  _      d S r#   r   )r?   r@   r   r   r   empty_fn      z'EmptyTqdm.__getattr__.<locals>.empty_fnr   )r>   _rF   r   r   r   __getattr__   s   zEmptyTqdm.__getattr__c                 C   s   | S r#   r   rC   r   r   r   	__enter__   rG   zEmptyTqdm.__enter__c                 C   rE   r#   r   )r>   type_value	tracebackr   r   r   __exit__   rG   zEmptyTqdm.__exit__N)	r    
__module____qualname____doc__rA   rD   rI   rJ   rN   r   r   r   r   r;      s    r;   Tc                   @   s$   e Zd Zdd Zdd Zdd ZdS )	_tqdm_clsc                 O   s"   t r
tj|i |S t|i |S r#   )_tqdm_activetqdm_libtqdmr;   r=   r   r   r   __call__   s   z_tqdm_cls.__call__c                 O   s    d | _ trtjj|i |S d S r#   )_lockrS   rT   rU   set_lockr=   r   r   r   rX      s   z_tqdm_cls.set_lockc                 C   s   t rtj S d S r#   )rS   rT   rU   get_lockrC   r   r   r   rY      s   
z_tqdm_cls.get_lockN)r    rO   rP   rV   rX   rY   r   r   r   r   rR      s    rR   c                   C   r0   )zCReturn a boolean indicating whether tqdm progress bars are enabled.)boolrS   r   r   r   r   is_progress_bar_enabled   s   r[   c                   C      da dS )Enable tqdm progress bar.TNrS   r   r   r   r   enable_progress_bar      r_   c                   C   r\   )r]   FNr^   r   r   r   r   disable_progress_bar   r`   ra   )r   Nr#   )*rQ   r   r   r   r   r   r   r   r   r   r	   typingr
   rU   r   rT   r   r   r   strr"   Loggerr$   r(   r)   r+   intr-   r/   r1   r3   r4   r5   r9   r:   r;   rS   rR   rZ   r[   r_   ra   r   r   r   r   <module>   sT   

	





	