From ed87c308ba0bb8780e59213343dcf049a6bcab91 Mon Sep 17 00:00:00 2001 From: Peter Rowlands Date: Thu, 13 Oct 2022 19:25:55 +0900 Subject: [PATCH] deps: bump dvc-data to 0.18.0 - callbacks: update to dvc-data 0.18.0 behavior --- dvc/fs/callbacks.py | 12 +++++++++--- dvc/output.py | 11 +++++++---- dvc/repo/checkout.py | 13 ++++++++----- setup.cfg | 2 +- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/dvc/fs/callbacks.py b/dvc/fs/callbacks.py index 61edc6ecc..dc8a509eb 100644 --- a/dvc/fs/callbacks.py +++ b/dvc/fs/callbacks.py @@ -1,6 +1,6 @@ # pylint: disable=unused-import from contextlib import ExitStack -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Any, BinaryIO, Dict, Optional, Union from funcy import cached_property @@ -75,10 +75,16 @@ class RichCallback(Callback): visible=not self.disable, ) - def branch(self, path_1, path_2, kwargs, child: Optional[Callback] = None): + def branch( + self, + path_1: Union[str, BinaryIO], + path_2: str, + kwargs: Dict[str, Any], + child: "Callback" = None, + ): child = child or RichCallback( progress=self.progress, - desc=path_1, + desc=path_1 if isinstance(path_1, str) else path_2, bytes=True, transient=self._transient, ) diff --git a/dvc/output.py b/dvc/output.py index 01cae1bca..e5833ca65 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -30,6 +30,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 from .utils import relpath from .utils.fs import path_isin @@ -38,6 +39,8 @@ if TYPE_CHECKING: from dvc_data.index import DataIndexKey from dvc_objects.db import ObjectDB + from .fs.callbacks import Callback + logger = logging.getLogger(__name__) @@ -827,7 +830,7 @@ class Output: def checkout( self, force=False, - progress_callback=None, + progress_callback: "Callback" = DEFAULT_CALLBACK, relink=False, filter_info=None, allow_missing=False, @@ -835,9 +838,9 @@ class Output: **kwargs, ): if not self.use_cache: - if progress_callback: - progress_callback( - self.fs_path, self.get_files_number(filter_info) + if progress_callback != DEFAULT_CALLBACK: + progress_callback.relative_update( + self.get_files_number(filter_info) ) return None diff --git a/dvc/repo/checkout.py b/dvc/repo/checkout.py index 079f33482..88611b394 100644 --- a/dvc/repo/checkout.py +++ b/dvc/repo/checkout.py @@ -7,7 +7,6 @@ from dvc.exceptions import ( CheckoutErrorSuggestGit, NoOutputOrStageError, ) -from dvc.progress import Tqdm from dvc.utils import relpath from . import locked @@ -80,6 +79,7 @@ def checkout( allow_missing=False, **kwargs, ): + from dvc.fs.callbacks import Callback stats = {"added": [], "deleted": [], "modified": [], "failed": []} if not targets: @@ -91,13 +91,16 @@ def checkout( pairs = _collect_pairs(self, targets, with_deps, recursive) total = get_all_files_numbers(pairs) - with Tqdm( - total=total, unit="file", desc="Checkout", disable=total == 0 - ) as pbar: + with Callback.as_tqdm_callback( + unit="file", + desc="Checkout", + disable=total == 0, + ) as cb: + cb.set_size(total) for stage, filter_info in pairs: result = stage.checkout( force=force, - progress_callback=pbar.update_msg, + progress_callback=cb, relink=relink, filter_info=filter_info, allow_missing=allow_missing, diff --git a/setup.cfg b/setup.cfg index a6d9eb50e..199e80540 100644 --- a/setup.cfg +++ b/setup.cfg @@ -67,7 +67,7 @@ install_requires = dvc-render==0.0.12 dvc-task==0.1.3 dvclive>=0.10.0 - dvc-data==0.17.1 + dvc-data==0.18.0 dvc-http==2.27.2 hydra-core>=1.1.0 iterative-telemetry==0.0.5