+
    ^\i)                     "  a  R t0 t R t^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RI	H
t
 ^ RIHtHtHtHtHt ^ RIHt ^RIHt / t] ^ k RR R lltRR	 R
 lltRR R lltR R lt ! R R]4      t]R R l4       tRRR^ RRRRRRRR/R R lltR# )u	  Utility helpers to handle progress bars in `huggingface_hub`.

Example:
    1. Use `huggingface_hub.utils.tqdm` as you would use `tqdm.tqdm` or `tqdm.auto.tqdm`.
    2. To disable progress bars, either use `disable_progress_bars()` helper or set the
       environment variable `HF_HUB_DISABLE_PROGRESS_BARS` to 1.
    3. To re-enable progress bars, use `enable_progress_bars()`.
    4. To check whether progress bars are disabled, use `are_progress_bars_disabled()`.

NOTE: Environment variable `HF_HUB_DISABLE_PROGRESS_BARS` has the priority.

Example:
    ```py
    >>> from huggingface_hub.utils import are_progress_bars_disabled, disable_progress_bars, enable_progress_bars, tqdm

    # Disable progress bars globally
    >>> disable_progress_bars()

    # Use as normal `tqdm`
    >>> for _ in tqdm(range(5)):
    ...    pass

    # Still not showing progress bars, as `disable=False` is overwritten to `True`.
    >>> for _ in tqdm(range(5), disable=False):
    ...    pass

    >>> are_progress_bars_disabled()
    True

    # Re-enable progress bars globally
    >>> enable_progress_bars()

    # Progress bar will be shown !
    >>> for _ in tqdm(range(5)):
    ...   pass
    100%|███████████████████████████████████████| 5/5 [00:00<00:00, 117817.53it/s]
    ```

Group-based control:
    ```python
    # Disable progress bars for a specific group
    >>> disable_progress_bars("peft.foo")

    # Check state of different groups
    >>> assert not are_progress_bars_disabled("peft"))
    >>> assert not are_progress_bars_disabled("peft.something")
    >>> assert are_progress_bars_disabled("peft.foo"))
    >>> assert are_progress_bars_disabled("peft.foo.bar"))

    # Enable progress bars for a subgroup
    >>> enable_progress_bars("peft.foo.bar")

    # Check if enabling a subgroup affects the parent group
    >>> assert are_progress_bars_disabled("peft.foo"))
    >>> assert not are_progress_bars_disabled("peft.foo.bar"))

    # No progress bar for `name="peft.foo"`
    >>> for _ in tqdm(range(5), name="peft.foo"):
    ...     pass

    # Progress bar will be shown for `name="peft.foo.bar"`
    >>> for _ in tqdm(range(5), name="peft.foo.bar"):
    ...     pass
    100%|███████████████████████████████████████| 5/5 [00:00<00:00, 117817.53it/s]

    ```
N)contextmanagernullcontext)Path)ContextManagerDictIteratorOptionalUnion)tqdm)HF_HUB_DISABLE_PROGRESS_BARSc                >    V ^8  d   QhR\         \        ,          RR/#    namereturnNr   str)formats   "r/Users/agent/.cache/uv/archive-v0/6ZL4-8mCcRNgGE9wi6M6J/lib/python3.14/site-packages/huggingface_hub/utils/tqdm.py__annotate__r   l   s     * * * *    c                ,   \         RJ d   \        P                  ! R4       R# V f    \        P	                  4        R\        R&   R# \         Uu. uF   qP                  V  R24      '       g   K  VNK"  	  ppV F
  p\        V K  	  R\        V &   R# u upi )a  
Disable progress bars either globally or for a specified group.

This function updates the state of progress bars based on a group name.
If no group name is provided, all progress bars are disabled. The operation
respects the `HF_HUB_DISABLE_PROGRESS_BARS` environment variable's setting.

Args:
    name (`str`, *optional*):
        The name of the group for which to disable the progress bars. If None,
        progress bars are disabled globally.

Raises:
    Warning: If the environment variable precludes changes.
FzlCannot disable progress bars: environment variable `HF_HUB_DISABLE_PROGRESS_BARS=0` is set and has priority.N_global.r   warningswarnprogress_bar_statesclear
startswithr   keykeys_to_removes   &  r   disable_progress_barsr#   l   s      $u,z	
 	|!!#).I&)<[)<#RVQWWXz@Z##)<[!C#C( "$)D! \   B.Bc                >    V ^8  d   QhR\         \        ,          RR/# r   r   )r   s   "r   r   r      s     ) )x} ) )r   c                ,   \         RJ d   \        P                  ! R4       R# V f    \        P	                  4        R\        R&   R# \         Uu. uF   qP                  V  R24      '       g   K  VNK"  	  ppV F
  p\        V K  	  R\        V &   R# u upi )a  
Enable progress bars either globally or for a specified group.

This function sets the progress bars to enabled for the specified group or globally
if no group is specified. The operation is subject to the `HF_HUB_DISABLE_PROGRESS_BARS`
environment setting.

Args:
    name (`str`, *optional*):
        The name of the group for which to enable the progress bars. If None,
        progress bars are enabled globally.

Raises:
    Warning: If the environment variable precludes changes.
TzkCannot enable progress bars: environment variable `HF_HUB_DISABLE_PROGRESS_BARS=1` is set and has priority.Nr   r   r   r    s   &  r   enable_progress_barsr'      s      $t+y	
 	|!!#)-I&)<[)<#RVQWWXz@Z##)<[!C#C( "$(D! \r$   c                F    V ^8  d   QhR\         \        ,          R\        /# )r   r   r   )r   r   bool)r   s   "r   r   r      s     8 8Xc] 8d 8r   c                "   \         RJ d   R# V f   \        P                  RR4      '       * # V '       dC   V \        9   d   \        V ,          '       * # RP                  V P	                  R4      RR 4      p KJ  \        P                  RR4      '       * # )a  
Check if progress bars are disabled globally or for a specific group.

This function returns whether progress bars are disabled for a given group or globally.
It checks the `HF_HUB_DISABLE_PROGRESS_BARS` environment variable first, then the programmatic
settings.

Args:
    name (`str`, *optional*):
        The group name to check; if None, checks the global setting.

Returns:
    `bool`: True if progress bars are disabled, False otherwise.
TNr   r   )r   r   getjoinsplit)r   s   &r   are_progress_bars_disabledr/      sw     $t+|&**9d;;;
&&*4000xx

3,-"&&y$777r   c                F    V ^8  d   QhR\         R\        \        ,          /# )r   	log_levelr   )intr   r)   )r   s   "r   r   r      s     
 
 
 
r   c                n    V \         P                  8X  d   R# \        P                  ! R4      R8X  d   R# R# )z
Determine if tqdm progress bars should be disabled based on logging level and environment settings.

see https://github.com/huggingface/huggingface_hub/pull/2000 and https://github.com/huggingface/huggingface_hub/pull/2698.
TTQDM_POSITIONz-1FN)loggingNOTSETosgetenvr1   s   &r   is_tqdm_disabledr:      s*     GNN"	yy!T)r   c                   N   a a ] tR t^t oRtV 3R ltV3R lV 3R lltRtVtV ;t	# )r
   z
Class to override `disable` argument in case progress bars are globally disabled.

Taken from https://github.com/tqdm/tqdm/issues/619#issuecomment-619639324.
c                x   < VP                  R R4      p\        V4      '       d   RVR&   \        SV `  ! V/ VB  R# )r   NTdisable)popr/   super__init__)selfargskwargsr   	__class__s   &*, r   r@   tqdm.__init__   s:    zz&$'%d++ $F9$)&)r   c                $   < V ^8  d   QhRS[ RR/# )r   attrr   N)r   )r   __classdict__s   "r   r   tqdm.__annotate__   s        r   c                \   <  \         SV `  V4       R#   \         d    TR8w  d   h  R# i ; i)zBFix for https://github.com/huggingface/huggingface_hub/issues/1603_lockN)r?   __delattr__AttributeError)rA   rG   rD   s   &&r   rL   tqdm.__delattr__   s3    	G% 	w 	s    ++ )
__name__
__module____qualname____firstlineno____doc__r@   rL   __static_attributes____classdictcell____classcell__)rD   rH   s   @@r   r
   r
      s     *  r   r
   c                |    V ^8  d   QhR\         \        \        3,          R\        \        P
                  ,          /# )r   pathr   )r	   r   r   r   ioBufferedReader)r   s   "r   r   r      s.     * *5s+ *9J9J0K *r   c           
   #    aa"   \        V \        4      '       d   \        V 4      p V P                  R4      ;_uu_ 4       pV P	                  4       P
                  p\        RRV^ V P                  R7      oVP                  oRR VV3R lllpW1n        Vx  SP                  4        RRR4       R#   + '       g   i     R# ; i5i)	u   
Open a file as binary and wrap the `read` method to display a progress bar when it's streamed.

First implemented in `transformers` in 2019 but removed when switched to git-lfs. Used in `huggingface_hub` to show
progress bar when uploading an LFS file to the Hub. See github.com/huggingface/transformers/pull/2078#discussion_r354739608
for implementation details.

Note: currently implementation handles only files stored on disk as it is the most common use case. Could be
      extended to stream any `BinaryIO` object but we might have to debug some corner cases.

Example:
```py
>>> with tqdm_stream_file("config.json") as f:
>>>     requests.put(url, data=f)
config.json: 100%|█████████████████████████| 8.19k/8.19k [00:02<00:00, 3.72kB/s]
```
rbBT)unit
unit_scaletotalinitialdescc                F    V ^8  d   QhR\         \        ,          R\        /# )r   sizer   )r   r2   bytes)r   s   "r   r   &tqdm_stream_file.<locals>.__annotate__  s     	 	hsm 	U 	r   c                 L   < S! V 4      pSP                  \        V4      4       V# N)updatelen)re   dataf_readpbars   & r   _inner_read%tqdm_stream_file.<locals>._inner_read  s!    $<DKKD	"Kr   N)r+   )

isinstancer   r   openstatst_sizer
   r   readclose)rY   f
total_sizero   rm   rn   s   &   @@r   tqdm_stream_filery      s     & $Dz	4AYY[((

 	 	
 

+ 
s   ;CA'B0&
C0C	;	Cra   rb   r_   r^   r`   Tr   	_tqdm_barc                    V ^8  d   QhR\         R\        R\        \        ,          R\        R\         R\        R\        \         ,          R\        \        ,          R	\
        \        ,          /	# )
r   rc   r1   ra   rb   r_   r`   r   rz   r   )r   r2   r   r)   r
   r   )r   s   "r   r   r     su      
  C=	
    3- ~ Dr   c                 X    Ve   \        V4      # \        VVVVV \        VR7      VR7      # )Nr9   )r_   r`   ra   rb   rc   r=   r   )r   r
   r:   )rc   r1   ra   rb   r_   r`   r   rz   s   $$$$$$$$r   _get_progress_bar_contextr}     s>     9%%
  95 r   c                b    V ^8  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   # )r   r   )__conditional_annotations__r   r   r)   )r   s   "r   r   r      s+     B Bt * )T#t)_ )uBr   ri   )r   rT   rZ   r5   r7   r   
contextlibr   r   pathlibr   typingr   r   r   r   r	   	tqdm.autor
   old_tqdm	constantsr   r   r#   r'   r/   r:   ry   r}   r   )r   s   @r   <module>r      s   BH 
  	  2  B B & 4 (*  )*@)@8:
8 , * *Z  	
     !% r   