Repository: iterative/dvc

Issue:
dvc push -q is not completely quiet, shows file transfer tqdm progress bars
Hey guys, love what you've done with DVC.

Had a quick bug that's causing me a little issue. When I use 'dvc push -q' I'm still seeing tqdm progress bars. Wouldn't be a huge issue, but I'm probably pushing 100K 250kb files. This is a local remote, so the transfer speeds are quick. I know in some of my other scripts where I use tqdm, if the iteration time is very small, the tqdm overhead of writing to std::out actually starts to contribute to performance.

dvc version: 0.83.0
os: Windows 10

![image](https://user-images.githubusercontent.com/45394583/74362981-a1500d80-4d97-11ea-9df8-c56fbadea69b.png)




Discussion:
casperdcl: any reason why `no_progress_bar=True` in these three places?

- `remote.gdrive.RemoteGDrive.gdrive_upload_file()`
- `remote.base.RemoteBASE._get_dir_info_checksum():self.cache.upload()`
- `remote.gs.RemoteGDrive.RemoteGS._upload()` and `_download()`
casperdcl: @efiop I think this is good to merge. I don't think it's worth reverting the `no_progress_bar=None` changes as I intend removing most of them in a future PR (see #3332).

Patch:
diff --git a/dvc/progress.py b/dvc/progress.py
index d03b037c0..a8ab61951 100644
--- a/dvc/progress.py
+++ b/dvc/progress.py
@@ -55,7 +55,8 @@ class Tqdm(tqdm):
         desc  : persists after `close()`
         level  : effective logging level for determining `disable`;
             used only if `disable` is unspecified
-        disable  : If (default: None), will be determined by logging level.
+        disable  : If (default: None) or False,
+            will be determined by logging level.
             May be overridden to `True` due to non-TTY status.
             Skip override by specifying env var `DVC_IGNORE_ISATTY`.
         kwargs  : anything accepted by `tqdm.tqdm()`
@@ -69,7 +70,7 @@ class Tqdm(tqdm):
             file = sys.stderr
         self.desc_persist = desc
         # auto-disable based on `logger.level`
-        if disable is None:
+        if not disable:
             disable = logger.getEffectiveLevel() > level
         # auto-disable based on TTY
         if (
diff --git a/dvc/repo/add.py b/dvc/repo/add.py
index fbbf7ed91..f216d6dde 100644
--- a/dvc/repo/add.py
+++ b/dvc/repo/add.py
@@ -73,7 +73,7 @@ def add(repo, targets, recursive=False, no_commit=False, fname=None):
                 total=len(stages),
                 desc="Processing",
                 unit="file",
-                disable=True if len(stages) == 1 else None,
+                disable=len(stages) == 1,
             ) as pbar_stages:
                 for stage in stages:
                     try:
@@ -120,7 +120,7 @@ def _create_stages(repo, targets, fname, pbar=None):
     for out in Tqdm(
         targets,
         desc="Creating DVC-files",
-        disable=True if len(targets) < LARGE_DIR_SIZE else None,
+        disable=len(targets) < LARGE_DIR_SIZE,
         unit="file",
     ):
         stage = Stage.create(


Test patch:
diff --git a/tests/unit/test_progress.py b/tests/unit/test_progress.py
index 72005f65c..30dd7e662 100644
--- a/tests/unit/test_progress.py
+++ b/tests/unit/test_progress.py
@@ -16,6 +16,17 @@ def test_quiet_logging(caplog, capsys):
         assert out_err.err == ""
 
 
+def test_quiet_logging_disable_false(caplog, capsys):
+    with caplog.at_level(logging.CRITICAL, logger="dvc"):
+        # simulate interactive terminal
+        with mock.patch.object(sys.stderr, "isatty", return_value=True):
+            for _ in Tqdm(range(10), disable=False):
+                pass
+            out_err = capsys.readouterr()
+            assert out_err.out == ""
+            assert out_err.err == ""
+
+
 def test_quiet_notty(caplog, capsys):
     with caplog.at_level(logging.INFO, logger="dvc"):
         for _ in Tqdm(range(10)):