Skip to content

Commit

Permalink
drop tqdm implementation and tqdm callback (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Feb 7, 2024
1 parent a7b0eed commit 41efa36
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 183 deletions.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ tests = [
dev = [
"dvc-objects[tests]",
"mypy==1.8.0",
"tqdm>=4.63.1,<5",
"types-tqdm",
"typing-extensions>=3.7.4",
]

[tool.setuptools.packages.find]
Expand Down
145 changes: 0 additions & 145 deletions src/dvc_objects/_tqdm.py

This file was deleted.

39 changes: 4 additions & 35 deletions src/dvc_objects/fs/callbacks.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
from functools import wraps
from typing import TYPE_CHECKING, BinaryIO, Optional, Type, cast

import fsspec
from fsspec.callbacks import DEFAULT_CALLBACK, Callback, NoOpCallback
from typing import TYPE_CHECKING, BinaryIO, cast

if TYPE_CHECKING:
from typing import Union

from tqdm import tqdm


__all__ = ["Callback", "NoOpCallback", "TqdmCallback", "DEFAULT_CALLBACK"]
import fsspec


class CallbackStream:
def __init__(self, stream, callback: Callback):
def __init__(self, stream, callback: "fsspec.Callback"):
self.stream = stream

@wraps(stream.read)
Expand All @@ -29,28 +21,5 @@ def __getattr__(self, attr):
return getattr(self.stream, attr)


class TqdmCallback(fsspec.callbacks.TqdmCallback):
def __init__(
self,
size: Optional[int] = None,
value: int = 0,
progress_bar: Optional["tqdm"] = None,
tqdm_cls: Optional[Type["tqdm"]] = None,
**tqdm_kwargs,
):
from dvc_objects._tqdm import Tqdm

tqdm_kwargs.pop("total", None)
super().__init__(
tqdm_kwargs=tqdm_kwargs, tqdm_cls=tqdm_cls or Tqdm, size=size, value=value
)
if progress_bar is not None:
self.tqdm = progress_bar

def branched(self, path_1: "Union[str, BinaryIO]", path_2: str, **kwargs):
desc = path_1 if isinstance(path_1, str) else path_2
return TqdmCallback(bytes=True, desc=desc)


def wrap_file(file, callback: Callback) -> BinaryIO:
def wrap_file(file, callback: "fsspec.Callback") -> BinaryIO:
return cast(BinaryIO, CallbackStream(file, callback))

0 comments on commit 41efa36

Please sign in to comment.