Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down Expand Up @@ -60,7 +60,7 @@ dev = [
]

[tool.setuptools.package-data]
dvc_objects = ["py.typed"]
scmrepo = ["py.typed"]

[tool.setuptools.packages.find]
where = ["src"]
Expand Down
10 changes: 6 additions & 4 deletions src/scmrepo/git/lfs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
23 changes: 7 additions & 16 deletions src/scmrepo/git/lfs/progress.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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(
Expand Down