From 6aee6b6b16440d26ad031000f96bd535873c1e32 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sun, 28 Jul 2019 14:54:37 +0100 Subject: [PATCH] add progress.Tqdm(bytes) --- dvc/progress.py | 7 +++++++ dvc/remote/http.py | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dvc/progress.py b/dvc/progress.py index 5fe0f60b9..3c483ccee 100644 --- a/dvc/progress.py +++ b/dvc/progress.py @@ -15,10 +15,17 @@ class Tqdm(tqdm): disable=logging.getLogger( __name__).getEffectiveLevel() >= logging.CRITICAL, ascii=None, # TODO: True? + bytes=False, **kwargs): """ + bytes : adds unit='B', unit_scale=True, unit_divisor=1024, miniters=1 kwargs : anything accepted by `tqdm.tqdm()` """ + if bytes: + #kwargs = deepcopy(kwargs) + for k, v in dict(unit='B', unit_scale=True, unit_divisor=1024, + miniters=1): + kwargs.setdefault(k, v) super(Tqdm, self).__init__( iterable=iterable, disable=disable, diff --git a/dvc/remote/http.py b/dvc/remote/http.py index 911e9754c..e662b9b9c 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -35,8 +35,7 @@ class RemoteHTTP(RemoteBASE): #if total: # leave = total > self.CHUNK_SIZE * 100 - with Tqdm(total=total, leave=leave, - unit='B', unit_scale=True, unit_divisor=1024, miniters=1, + with Tqdm(total=total, leave=leave, bytes=True, disable=no_progress_bar) as pbar: with open(to_file, "wb") as fd: for chunk in request.iter_content(chunk_size=self.CHUNK_SIZE):