+
    LV-jú#  ã                   óz   € ^ RI Ht  ! R R4      t ! R R]4      t ! R R]4      t ! R R	]4      t]! 4       ;ttR
# )é    ©Úwrapsc                   ó˜   a € ] tR t^t o RtRR ltR tR tR tR t	R t
R	 tR
 tRR ltRR ltR tR tR tR t]RR l4       tRtV tR# )ÚCallbackah  
Base class and interface for callback mechanism

This class can be used directly for monitoring file transfers by
providing ``callback=Callback(hooks=...)`` (see the ``hooks`` argument,
below), or subclassed for more specialised behaviour.

Parameters
----------
size: int (optional)
    Nominal quantity for the value that corresponds to a complete
    transfer, e.g., total number of tiles or total number of
    bytes
value: int (0)
    Starting internal counter value
hooks: dict or None
    A dict of named functions to be called on each update. The signature
    of these must be ``f(size, value, **kwargs)``
Nc                óL   € Wn         W n        T;'       g    / V n        W@n        R # ©N)ÚsizeÚvalueÚhooksÚkw)Úselfr	   r
   r   Úkwargss   &&&&,Úa/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/fsspec/callbacks.pyÚ__init__ÚCallback.__init__   s   € ØŒ	ØŒ
Ø—[�[˜bˆŒ
ØŽó    c                ó   € V # r   © ©r   s   &r   Ú	__enter__ÚCallback.__enter__   s   € Øˆr   c                ó&   € V P                  4        R # r   ©Úclose)r   Úexc_argss   &*r   Ú__exit__ÚCallback.__exit__"   s   € Ø�
‰
Žr   c                ó   € R# )zClose callback.Nr   r   s   &r   r   ÚCallback.close%   s   ‚ r   c                óR   € V P                  WV4       VP                  R\        4      # )aê  
Return callback for child transfers

If this callback is operating at a higher level, e.g., put, which may
trigger transfers that can also be monitored. The function returns a callback
that has to be passed to the child method, e.g., put_file,
as `callback=` argument.

The implementation uses `callback.branch` for compatibility.
When implementing callbacks, it is recommended to override this function instead
of `branch` and avoid calling `super().branched(...)`.

Prefer using this function over `branch`.

Parameters
----------
path_1: str
    Child's source path
path_2: str
    Child's destination path
**kwargs:
    Arbitrary keyword arguments

Returns
-------
callback: Callback
    A callback instance to be passed to the child method
Úcallback)ÚbranchÚpopÚDEFAULT_CALLBACK©r   Úpath_1Úpath_2r   s   &&&,r   ÚbranchedÚCallback.branched(   s$   € ð: 	�‰�F FÔ+à�z‰z˜*Ô&6Ó7Ð7r   c                ó:   a a€ \        S4      R VV 3R ll4       pV# )z9
Wraps a coroutine, and pass a new child callback to it.
c                ó$   € V ^8„  d   QhR\         /# )é   Úpath2)Ústr)Úformats   "r   Ú__annotate__Ú*Callback.branch_coro.<locals>.__annotate__O   s   € ÷ 	Hñ 	H¤Sñ 	Hr   c              ›   óª   <"  € SP                   ! W3/ VB ;_uu_ 4       pS! W3R V/VB G Rj  x€L
 uuRRR4       #  L  + '       g   i     R# ; i5i)r!   N)r(   )Úpath1r-   r   ÚchildÚfnr   s   &&, €€r   ÚfuncÚ"Callback.branch_coro.<locals>.funcN   sG   øé € à—’˜uÑ6¨v×6Ò6¸%Ù ÑG°uÐGÀÑG×G÷ 7Ò6ÙG÷ 7×6Ð6üs%   ƒAŸ?®=¯?²A½?¿A	Á
	Ar   )r   r5   r6   s   ff r   Úbranch_coroÚCallback.branch_coroI   s*   ù€ ô
 
ˆr‹÷	Hð 	Hó 
ð	Hð ˆr   c                ó2   € Wn         V P                  4        R# )z§
Set the internal maximum size attribute

Usually called if not initially set at instantiation. Note that this
triggers a ``call()``.

Parameters
----------
size: int
N)r	   Úcall)r   r	   s   &&r   Úset_sizeÚCallback.set_sizeU   s   € ð Œ	Ø�	‰	Žr   c                ó2   € Wn         V P                  4        R# )zU
Set the internal value state

Triggers ``call()``

Parameters
----------
value: int
N©r
   r;   )r   r
   s   &&r   Úabsolute_updateÚCallback.absolute_updatec   s   € ð Œ
Ø�	‰	Žr   c                óX   € V ;P                   V,          un         V P                  4        R# )z[
Delta increment the internal counter

Triggers ``call()``

Parameters
----------
inc: int
Nr?   )r   Úincs   &&r   Úrelative_updateÚCallback.relative_updatep   s   € ð 	�
Š
�cÕ�
Ø�	‰	Žr   c                ó¨  € V P                   '       g   R# V P                  P                  4       pVP                  V4       V'       dB   WP                   9  d   R# V P                   V,          ! V P                  V P
                  3/ VB # V P                   P                  4       ;'       g    .  F!  pV! V P                  V P
                  3/ VB  K#  	  R# )zÕ
Execute hook(s) with current state

Each function is passed the internal size and current value

Parameters
----------
hook_name: str or None
    If given, execute on this hook
kwargs: passed on to (all) hook(s)
N)r   r   ÚcopyÚupdater	   r
   Úvalues)r   Ú	hook_namer   r   Úhooks   &&,  r   r;   ÚCallback.call}   s—   € ð �z�zˆzÙØ�W‰W�\‰\‹^ˆØ
�	‰	�&ÔßØ§
¡
Ô*ÙØ—:‘:˜iÖ(¨¯©°D·J±JÑEÀ"ÑEÐEØ—J‘J×%Ñ%Ó'×-Ð-¨2Ò-ˆDÙ�—‘˜DŸJ™JÑ-¨"Ô-ó .r   c              #  óH   "  € V F  pV P                  4        Vx € K  	  R# 5i)z’
Wrap an iterable to call ``relative_update`` on each iterations

Parameters
----------
iterable: Iterable
    The iterable that is being wrapped
N)rD   )r   ÚiterableÚitems   && r   ÚwrapÚCallback.wrap”   s"   é € ó ˆDØ× Ñ Ô"ØŒJó ùs   ‚ "c                ó   € R# )a»  
Set callbacks for child transfers

If this callback is operating at a higher level, e.g., put, which may
trigger transfers that can also be monitored. The passed kwargs are
to be *mutated* to add ``callback=``, if this class supports branching
to children.

Parameters
----------
path_1: str
    Child's source path
path_2: str
    Child's destination path
kwargs: dict
    arguments passed to child method, e.g., put_file.

Returns
-------

Nr   r%   s   &&&&r   r"   ÚCallback.branch¡   s   € ñ, r   c                ó   € R # r   r   )r   Ú_Ú__s   &*,r   Úno_opÚCallback.no_op¹   s   € Ùr   c                ó   € V P                   # )z@
If undefined methods are called on this class, nothing happens
)rW   )r   rO   s   &&r   Ú__getattr__ÚCallback.__getattr__¼   s   € ð �z‰zÐr   c                ó   € Vf   \         # V# )zäTransform callback=... into Callback instance

For the special value of ``None``, return the global instance of
``NoOpCallback``. This is an alternative to including
``callback=DEFAULT_CALLBACK`` directly in a method signature.
)r$   )ÚclsÚmaybe_callbacks   &&r   Úas_callbackÚCallback.as_callbackÂ   s   € ð Ò!Ü#Ð#ØÐr   )r   r   r	   r
   )Nr   N)é   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r   r(   r8   r<   r@   rD   r;   rP   r"   rW   rZ   Úclassmethodr_   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      se   ø‡ € ñô(òòòò8òB
òòôô.ò.òò0òð ó	ó ö	r   r   c                   ó*   a € ] tR t^Ït o RtR tRtV tR# )ÚNoOpCallbackz6
This implementation of Callback does exactly nothing
c                ó   € R # r   r   ©r   Úargsr   s   &*,r   r;   ÚNoOpCallback.callÔ   s   € Ùr   r   N)rb   rc   rd   re   rf   r;   rh   ri   rj   s   @r   rm   rm   Ï   s   ø‡ € ñ÷ð r   rm   c                   óF   a a€ ] tR t^Øt oRtRV 3R lltR tR tRtVt	V ;t
# )ÚDotPrinterCallbackz´
Simple example Callback implementation

Almost identical to Callback with a hook that prints a char; here we
demonstrate how the outer layer may print "#" and the inner layer "."
c                ó4   <€ Wn         \        SV `  ! R/ VB  R # )Nr   )ÚchrÚsuperr   )r   Úchr_to_printr   Ú	__class__s   &&,€r   r   ÚDotPrinterCallback.__init__à   s   ø€ ØŒÜ‰ÒÑ"˜6Ô"r   c                ó"   € \        R4      VR&   R# )z;Mutate kwargs to add new instance with different print charÚ.r!   N)rs   r%   s   &&&&r   r"   ÚDotPrinterCallback.branchä   s   € ä/°Ó4ˆˆzÓr   c                ó4   € \        V P                  RR7       R# )zJust outputs a characterÚ )ÚendN)Úprintru   )r   r   s   &,r   r;   ÚDotPrinterCallback.callè   s   € äˆd�h‰h˜B×r   )ru   )Ú#)rb   rc   rd   re   rf   r   r"   r;   rh   ri   Ú__classcell__©rx   rk   s   @@r   rs   rs   Ø   s   ù‡ € ñ÷#ò5÷ ò  r   rs   c                   óL   a a€ ] tR t^ít oRtRV 3R lltR tR tR tRt	Vt
V ;t# )ÚTqdmCallbacka7  
A callback to display a progress bar using tqdm

Parameters
----------
tqdm_kwargs : dict, (optional)
    Any argument accepted by the tqdm constructor.
    See the `tqdm doc <https://tqdm.github.io/docs/tqdm/#__init__>`_.
    Will be forwarded to `tqdm_cls`.
tqdm_cls: (optional)
    subclass of `tqdm.tqdm`. If not passed, it will default to `tqdm.tqdm`.

Examples
--------
>>> import fsspec
>>> from fsspec.callbacks import TqdmCallback
>>> fs = fsspec.filesystem("memory")
>>> path2distant_data = "/your-path"
>>> fs.upload(
        ".",
        path2distant_data,
        recursive=True,
        callback=TqdmCallback(),
    )

You can forward args to tqdm using the ``tqdm_kwargs`` parameter.

>>> fs.upload(
        ".",
        path2distant_data,
        recursive=True,
        callback=TqdmCallback(tqdm_kwargs={"desc": "Your tqdm description"}),
    )

You can also customize the progress bar by passing a subclass of `tqdm`.

.. code-block:: python

    class TqdmFormat(tqdm):
        '''Provides a `total_time` format parameter'''
        @property
        def format_dict(self):
            d = super().format_dict
            total_time = d["elapsed"] * (d["total"] or 0) / max(d["n"], 1)
            d.update(total_time=self.format_interval(total_time) + " in total")
            return d

>>> with TqdmCallback(
        tqdm_kwargs={
            "desc": "desc",
            "bar_format": "{total_time}: {percentage:.0f}%|{bar}{r_bar}",
        },
        tqdm_cls=TqdmFormat,
    ) as callback:
        fs.upload(".", path2distant_data, recursive=True, callback=callback)
c                óÒ   <€  ^ RI H p TP                  RT4      T n        T;'       g    / T n        RT n         \
        ST `  ! T/ TB  R#   \         d   p\        R4      ThRp?ii ; i)r   )Útqdmz0Using TqdmCallback requires tqdm to be installedNÚtqdm_cls)rˆ   ÚImportErrorr#   Ú	_tqdm_clsÚ_tqdm_kwargsrv   r   )r   Útqdm_kwargsrp   r   rˆ   Úexcerx   s   &&*,  €r   r   ÚTqdmCallback.__init__'  sm   ø€ ð	Ý!ð  Ÿ™ J°Ó5ˆŒØ'×-Ð-¨2ˆÔØˆŒ	Ü‰Ò˜$Ð) &Ô)øô ô 	ÜØBóàðûð	ús   ƒA
 Á
A&ÁA!Á!A&c                ó2  € V P                   f.   V P                  ! RRV P                  /V P                  B V n         V P                  V P                   n        V P                   P                  V P                  V P                   P                  ,
          4       R # )NÚtotalr   )rˆ   r‹   r	   rŒ   r‘   rH   r
   Únro   s   &*,r   r;   ÚTqdmCallback.call5  s`   € Ø�9‰9ÒØŸšÑL¨T¯Y©YÐL¸$×:KÑ:KÑLˆDŒIØŸ)™)ˆ�	‰	ŒØ�	‰	×Ñ˜Ÿ™ d§i¡i§k¡kÕ1Ö2r   c                óh   € V P                   e$   V P                   P                  4        R V n         R # R # r   )rˆ   r   r   s   &r   r   ÚTqdmCallback.close;  s&   € Ø�9‰9Ò Ø�I‰I�O‰OÔØˆDŽIñ !r   c                ó"   € V P                  4       # r   r   r   s   &r   Ú__del__ÚTqdmCallback.__del__@  s   € Ø�z‰z‹|Ðr   )r‹   rŒ   rˆ   r   )rb   rc   rd   re   rf   r   r;   r   r—   rh   ri   rƒ   r„   s   @@r   r†   r†   í   s$   ù‡ € ñ7÷r*ò3ò÷
ò r   r†   N)Ú	functoolsr   r   rm   rs   r†   r$   Ú_DEFAULT_CALLBACKr   r   r   Ú<module>r›      sL   ðÝ ÷Hñ HôV�8ô ô ˜ô  ô*T�8ô Tñn (4£~Ð 5Ð Ò$r   