MCPcopy
hub / github.com/treeverse/dvc / lfs_prefetch

Function lfs_prefetch

dvc/scm.py:267–291  ·  view source on GitHub ↗
(fs: "FileSystem", paths: list[str])

Source from the content-addressed store, hash-verified

265
266
267def lfs_prefetch(fs: "FileSystem", paths: list[str]):
268 from scmrepo.git.lfs import fetch as _lfs_fetch
269
270 from dvc.fs.dvc import DVCFileSystem
271 from dvc.fs.git import GitFileSystem
272
273 if isinstance(fs, DVCFileSystem) and isinstance(fs.repo.fs, GitFileSystem):
274 git_fs = fs.repo.fs
275 scm = fs.repo.scm
276 assert isinstance(scm, Git)
277 else:
278 return
279
280 try:
281 if "filter=lfs" not in git_fs.open(".gitattributes").read():
282 return
283 except OSError:
284 return
285 with TqdmGit(desc="Checking for Git-LFS objects") as pbar:
286 _lfs_fetch(
287 scm,
288 [git_fs.rev],
289 include=[(path if path.startswith("/") else f"/{path}") for path in paths],
290 progress=pbar.update_git,
291 )
292
293
294def add_no_submodules(

Callers 2

downloadFunction · 0.90
test_lfs_prefetchFunction · 0.90

Calls 3

TqdmGitClass · 0.85
openMethod · 0.80
readMethod · 0.45

Tested by 1

test_lfs_prefetchFunction · 0.72