From 915dd5062ef05745b4612fe35da3906f0df2971a Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Fri, 12 May 2023 18:43:33 +0545 Subject: [PATCH] disable nested progress bar during checkout (#9446) --- dvc/output.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/dvc/output.py b/dvc/output.py index e6295e233..a11a36960 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -36,7 +36,7 @@ from dvc_objects.errors import ObjectFormatError from .annotations import ANNOTATION_FIELDS, ANNOTATION_SCHEMA, Annotation from .fs import LocalFileSystem, RemoteMissingDepsError, Schemes, get_cloud_fs -from .fs.callbacks import DEFAULT_CALLBACK, Callback +from .fs.callbacks import DEFAULT_CALLBACK, Callback, TqdmCallback from .utils import relpath from .utils.fs import path_isin @@ -276,6 +276,11 @@ class OutputIsIgnoredError(DvcException): super().__init__(f"Path '{match.file}' is ignored by\n{lines}") +class CheckoutCallback(TqdmCallback): + # disable branching for checkouts + branch = Callback.branch # type: ignore[assignment] + + class Output: IS_DEPENDENCY = False @@ -740,9 +745,7 @@ class Output: ) if relink: rel = self.fs.path.relpath(filter_info or self.fs_path) - with Callback.as_tqdm_callback( - desc=f"Checking out {rel}", unit="files" - ) as callback: + with CheckoutCallback(desc=f"Checking out {rel}", unit="files") as cb: self._checkout( filter_info or self.fs_path, self.fs, @@ -751,7 +754,7 @@ class Output: relink=True, state=self.repo.state, prompt=prompt.confirm, - progress_callback=callback, + progress_callback=cb, ) self.set_exec() @@ -901,9 +904,6 @@ class Output: progress_callback.relative_update(inc) return super().relative_update(inc) - def branch(self, *args, **kwargs): - return progress_callback.branch(*args, **kwargs) - callback = CallbackProxy() if not self.use_cache: callback.relative_update(self.get_files_number(filter_info)) @@ -1357,9 +1357,7 @@ class Output: if relink: rel = self.fs.path.relpath(path) - with Callback.as_tqdm_callback( - desc=f"Checking out {rel}", unit="files" - ) as callback: + with CheckoutCallback(desc=f"Checking out {rel}", unit="files") as callback: self._checkout( path, self.fs,