Skip to content

Commit

Permalink
TqdmCallback: add support for custom tqdm subclasses
Browse files Browse the repository at this point in the history
This will allow customizing the tqdm progressbar used for the callback,
and extending (since all `tqdm_kwargs` is passed to the underlying
implementation.)

Eg: in dvc, we have custom logic to align all the _progress_ _bars_
of tqdm, even if they have different description length.
  • Loading branch information
skshetry committed Jan 23, 2024
1 parent ec13d27 commit 348c8a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fsspec/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ class TqdmCallback(Callback):
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.
Will be forwarded to `tqdm_cls`.
tqdm_cls: (optional)
subclass of `tqdm.tqdm`. If not passed, it will default to `tqdm.tqdm`.
Examples
--------
Expand Down Expand Up @@ -277,7 +279,7 @@ def __init__(self, tqdm_kwargs=None, *args, **kwargs):
"Using TqdmCallback requires tqdm to be installed"
) from exce

self._tqdm_cls = tqdm
self._tqdm_cls = kwargs.pop("tqdm_cls", tqdm)
self._tqdm_kwargs = tqdm_kwargs or {}
self.tqdm = None
super().__init__(*args, **kwargs)
Expand Down

0 comments on commit 348c8a7

Please sign in to comment.