From f88bf9218a4b3ae0dda08a4d55ede9785b4c270f Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 10 Aug 2019 14:41:08 +0100 Subject: [PATCH] tqdm auto-disabling with dynamic log level --- dvc/progress.py | 8 ++++++-- dvc/remote/local/__init__.py | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dvc/progress.py b/dvc/progress.py index 17085a48a..8069ca0bc 100644 --- a/dvc/progress.py +++ b/dvc/progress.py @@ -12,8 +12,7 @@ class Tqdm(tqdm): def __init__( self, iterable=None, - disable=logging.getLogger(__name__).getEffectiveLevel() - >= logging.CRITICAL, + disable=None, bytes=False, # pylint: disable=W0622 desc_truncate=None, **kwargs @@ -32,6 +31,11 @@ class Tqdm(tqdm): kwargs.setdefault(k, v) if desc_truncate is not None: kwargs.setdefault("desc", self.truncate(desc_truncate)) + if disable is None: + disable = ( + logging.getLogger(__name__).getEffectiveLevel() + >= logging.CRITICAL + ) super(Tqdm, self).__init__( iterable=iterable, disable=disable, **kwargs ) diff --git a/dvc/remote/local/__init__.py b/dvc/remote/local/__init__.py index 22ec5377d..7c50a6435 100644 --- a/dvc/remote/local/__init__.py +++ b/dvc/remote/local/__init__.py @@ -348,9 +348,7 @@ class RemoteLOCAL(RemoteBASE): cache = [] path_infos = [] names = [] - for md5, info in Tqdm( - status_info.items(), desc="Analysing status" - ): + for md5, info in Tqdm(status_info.items(), desc="Analysing status"): if info["status"] == status: cache.append(self.checksum_to_path_info(md5)) path_infos.append(remote.checksum_to_path_info(md5))