From 5a7bee45083a318595bcc374194966b07a46e562 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sat, 10 Mar 2018 18:18:02 +0200 Subject: [PATCH] dvc: fix progress bar Signed-off-by: Ruslan Kuprieiev --- dvc/cloud/local.py | 5 +---- dvc/progress.py | 1 + dvc/utils.py | 8 +++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dvc/cloud/local.py b/dvc/cloud/local.py index 5a606a7bb..880937129 100644 --- a/dvc/cloud/local.py +++ b/dvc/cloud/local.py @@ -15,9 +15,6 @@ class LocalKey(object): def path(self): return os.path.join(self.bucket, self.name) - def delete(self): - os.unlink(self.path) - class DataCloudLOCAL(DataCloudBase): """ @@ -52,7 +49,7 @@ class DataCloudLOCAL(DataCloudBase): tmp_file = self.tmp_file(path) try: - copyfile(key.path, tmp_file) + copyfile(key.path, tmp_file, no_progress_bar=no_progress_bar) except Exception as exc: Logger.error('Failed to copy "{}": {}'.format(key.path, exc)) return None diff --git a/dvc/progress.py b/dvc/progress.py index a6652911e..64ea7ed95 100644 --- a/dvc/progress.py +++ b/dvc/progress.py @@ -13,6 +13,7 @@ class Progress(object): def set_n_total(self, total): self._n_total = total + self._n_finished = 0 def _clearln(self): print('\r\x1b[K', end='') diff --git a/dvc/utils.py b/dvc/utils.py index 19e022e23..b9aaf62a1 100644 --- a/dvc/utils.py +++ b/dvc/utils.py @@ -45,7 +45,7 @@ def cached_property(func): return property(get) -def copyfile(src, dest): +def copyfile(src, dest, no_progress_bar=False): '''Copy file with progress bar''' copied = 0 name = os.path.basename(src) @@ -64,9 +64,11 @@ def copyfile(src, dest): break fdest.write(buf) copied += len(buf) - progress.update_target(name, copied, total) + if not no_progress_bar: + progress.update_target(name, copied, total) - progress.finish_target(name) + if not no_progress_bar: + progress.finish_target(name) fsrc.close() fdest.close()