From ddb7c8e3592937386f3a22efb0082639d29b51cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Mon, 5 Feb 2024 19:48:09 +0545 Subject: [PATCH] deps: bump dvc-objects to >= 4 --- pyproject.toml | 6 +++--- src/scmrepo/git/lfs/client.py | 10 ++++++---- src/scmrepo/git/lfs/progress.py | 23 +++++++---------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d0b0809a..0693e194 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,12 +25,12 @@ dependencies = [ "dulwich>=0.21.6", "pygit2>=1.14.0", "pygtrie>=2.3.2", - "fsspec>=2021.7.0", + "fsspec>=2024.2.0", "pathspec>=0.9.0", "asyncssh>=2.13.1,<3", "funcy>=1.14", "shortuuid>=0.5.0", - "dvc-objects>=3,<4", + "dvc-objects>=4,<5", "dvc-http>=2.29.0", ] @@ -60,7 +60,7 @@ dev = [ ] [tool.setuptools.package-data] -dvc_objects = ["py.typed"] +scmrepo = ["py.typed"] [tool.setuptools.packages.find] where = ["src"] diff --git a/src/scmrepo/git/lfs/client.py b/src/scmrepo/git/lfs/client.py index 6724602c..5fef7ed3 100644 --- a/src/scmrepo/git/lfs/client.py +++ b/src/scmrepo/git/lfs/client.py @@ -7,9 +7,9 @@ from dvc_http import HTTPFileSystem from dvc_objects.executors import batch_coros from dvc_objects.fs import localfs -from dvc_objects.fs.callbacks import DEFAULT_CALLBACK from dvc_objects.fs.utils import as_atomic from fsspec.asyn import sync_wrapper +from fsspec.callbacks import DEFAULT_CALLBACK from funcy import cached_property from scmrepo.git.credentials import Credential, CredentialNotFoundError @@ -18,7 +18,7 @@ from .pointer import Pointer if TYPE_CHECKING: - from dvc_objects.fs.callbacks import Callback + from fsspec.callbacks import Callback from .storage import LFSStorage @@ -142,8 +142,10 @@ async def _download( ): async def _get_one(from_path: str, to_path: str, **kwargs): with as_atomic(localfs, to_path, create_parents=True) as tmp_file: - with callback.branch(from_path, tmp_file, kwargs): - await self.httpfs._get_file(from_path, tmp_file, **kwargs) # pylint: disable=protected-access + with callback.branched(from_path, tmp_file) as child: + await self.httpfs._get_file( + from_path, tmp_file, callback=child, **kwargs + ) # pylint: disable=protected-access callback.relative_update() resp_data = await self._batch_request(objects, **kwargs) diff --git a/src/scmrepo/git/lfs/progress.py b/src/scmrepo/git/lfs/progress.py index fa21d2de..088edab7 100644 --- a/src/scmrepo/git/lfs/progress.py +++ b/src/scmrepo/git/lfs/progress.py @@ -1,6 +1,7 @@ -from typing import Any, BinaryIO, Callable, Optional, Union +from typing import BinaryIO, Callable, Optional, Union -from dvc_objects.fs.callbacks import DEFAULT_CALLBACK, Callback, TqdmCallback +from dvc_objects.fs.callbacks import TqdmCallback +from fsspec.callbacks import DEFAULT_CALLBACK, Callback from scmrepo.progress import GitProgressEvent @@ -33,22 +34,12 @@ def _update_git(self): ) self.git_progress(event) - def branch( - self, - path_1: Union[str, BinaryIO], - path_2: str, - kwargs: dict[str, Any], - child: Optional[Callback] = None, - ): - if child: - pass - elif self.git_progress: - child = TqdmCallback( + def branched(self, path_1: Union[str, BinaryIO], path_2: str, **kwargs): + if self.git_progress: + return TqdmCallback( bytes=True, desc=path_1 if isinstance(path_1, str) else path_2 ) - else: - child = DEFAULT_CALLBACK - return super().branch(path_1, path_2, kwargs, child=child) + return DEFAULT_CALLBACK @classmethod def as_lfs_callback(