From af255a46b489792135801d33a100f1db0e8ef56b Mon Sep 17 00:00:00 2001 From: Peter Rowlands Date: Tue, 22 Nov 2022 18:57:47 +0900 Subject: [PATCH] worktree: use progress bars in push/fetch --- dvc/repo/worktree.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/dvc/repo/worktree.py b/dvc/repo/worktree.py index 0b3f5cadb..8eebc8f0d 100644 --- a/dvc/repo/worktree.py +++ b/dvc/repo/worktree.py @@ -1,5 +1,7 @@ from typing import TYPE_CHECKING, Optional +from dvc.fs.callbacks import Callback + if TYPE_CHECKING: from dvc.cloud import Remote from dvc.index import Index, IndexView @@ -57,7 +59,12 @@ def fetch_worktree(repo: "Repo", remote: "Remote") -> int: remote.path, *key, ) - return save(index) + total = len(index) + with Callback.as_tqdm_callback( + unit="file", desc="Fetch", disable=total == 0 + ) as cb: + cb.set_size(total) + return save(index, callback=cb) def push_worktree(repo: "Repo", remote: "Remote") -> int: @@ -66,7 +73,18 @@ def push_worktree(repo: "Repo", remote: "Remote") -> int: view = worktree_view(repo.index, push=True) index = view.data["repo"] - pushed = checkout(index, remote.path, remote.fs, latest_only=False) + total = len(index) + with Callback.as_tqdm_callback( + unit="file", desc="Push", disable=total == 0 + ) as cb: + cb.set_size(total) + pushed = checkout( + index, + remote.path, + remote.fs, + latest_only=False, + callback=cb, + ) for stage in view.stages: for out in stage.outs: