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

Method du

dvc/fs/dvc.py:624–661  ·  view source on GitHub ↗
(self, path, total=True, maxdepth=None, withdirs=False, **kwargs)

Source from the content-addressed store, hash-verified

622 return dvc_fs.get_file(dvc_path, lpath, info=dvc_info, **kwargs)
623
624 def du(self, path, total=True, maxdepth=None, withdirs=False, **kwargs):
625 if maxdepth is not None:
626 raise NotImplementedError
627
628 sizes = {}
629 dus = {}
630 todo = deque([self.info(path)])
631 while todo:
632 info = todo.popleft()
633 isdir = info["type"] == "directory"
634 size = info["size"] or 0
635 name = info["name"]
636
637 if not isdir:
638 sizes[name] = size
639 continue
640
641 dvc_info = info.get("dvc_info") or {}
642 fs_info = info.get("fs_info")
643 entry = dvc_info.get("entry")
644 if (
645 dvc_info
646 and not fs_info
647 and entry is not None
648 and entry.size is not None
649 ):
650 dus[name] = entry.size
651 continue
652
653 if withdirs:
654 sizes[name] = size
655
656 todo.extend(self.ls(info["name"], detail=True))
657
658 if total:
659 return sum(sizes.values()) + sum(dus.values())
660
661 return sizes
662
663 def close(self):
664 self._repo_stack.close()

Callers 3

runMethod · 0.80
duFunction · 0.80
test_duFunction · 0.80

Calls 4

infoMethod · 0.95
lsMethod · 0.95
extendMethod · 0.80
getMethod · 0.45

Tested by 1

test_duFunction · 0.64