From adcefbec66659bf94673684d62c17c79d5e1608d Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sun, 9 Jul 2023 05:00:34 +0300 Subject: [PATCH] output: pass explicit callback to hashfile.build() --- dvc/output.py | 26 +++++++++++++++++++------- pyproject.toml | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/dvc/output.py b/dvc/output.py index 143dd518a..0cbb52115 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -548,12 +548,24 @@ class Output: _, hash_info = self._get_hash_meta() return hash_info + def _build( + self, *args, no_progress_bar=False, **kwargs + ) -> Tuple["HashFileDB", "Meta", "HashFile"]: + from dvc.ui import ui + + with ui.progress( + unit="file", + desc=f"Collecting files and computing hashes in {self}", + disable=no_progress_bar, + ) as pb: + return build(*args, callback=pb.as_callback(), **kwargs) + def _get_hash_meta(self): if self.use_cache: odb = self.cache else: odb = self.local_cache - _, meta, obj = build( + _, meta, obj = self._build( odb, self.fs_path, self.fs, @@ -703,7 +715,7 @@ class Output: self._update_legacy_hash_name() if self.use_cache: - _, self.meta, self.obj = build( + _, self.meta, self.obj = self._build( self.cache, self.fs_path, self.fs, @@ -711,7 +723,7 @@ class Output: ignore=self.dvcignore, ) else: - _, self.meta, self.obj = build( + _, self.meta, self.obj = self._build( self.local_cache, self.fs_path, self.fs, @@ -763,7 +775,7 @@ class Output: if granular: obj = self._commit_granular_dir(filter_info, hardlink) else: - staging, _, obj = build( + staging, _, obj = self._build( self.cache, filter_info or self.fs_path, self.fs, @@ -794,7 +806,7 @@ class Output: def _commit_granular_dir(self, filter_info, hardlink) -> Optional["HashFile"]: prefix = self.fs.path.parts(self.fs.path.relpath(filter_info, self.fs_path)) - staging, _, obj = build( + staging, _, obj = self._build( self.cache, self.fs_path, self.fs, @@ -1021,7 +1033,7 @@ class Output: upload = not (update and from_fs.isdir(from_info)) jobs = jobs or min((from_fs.jobs, odb.fs.jobs)) - staging, self.meta, obj = build( + staging, self.meta, obj = self._build( odb, from_info, from_fs, @@ -1357,7 +1369,7 @@ class Output: new: "HashFile" try: assert self.hash_name - staging, meta, obj = build( + staging, meta, obj = self._build( cache, path, self.fs, diff --git a/pyproject.toml b/pyproject.toml index 2e5389562..da5b4586e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "configobj>=5.0.6", "distro>=1.3", "dpath<3,>=2.1.0", - "dvc-data>=2.3.2,<2.4.0", + "dvc-data>=2.4.1,<2.5.0", "dvc-http>=2.29.0", "dvc-render>=0.3.1,<1", "dvc-studio-client>=0.9.2,<1",