Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: fix missing progress & tidy #3334

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions dvc/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def __init__(
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()`
Expand All @@ -69,7 +70,7 @@ def __init__(
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 (
Expand Down
2 changes: 1 addition & 1 deletion dvc/remote/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def _get_dir_info_checksum(self, dir_info):

from_info = PathInfo(tmp)
to_info = self.cache.path_info / tmp_fname("")
self.cache.upload(from_info, to_info, no_progress_bar=True)
self.cache.upload(from_info, to_info, no_progress_bar=False)

checksum = self.get_file_checksum(to_info) + self.CHECKSUM_DIR_SUFFIX
return checksum, to_info
Expand Down
2 changes: 1 addition & 1 deletion dvc/remote/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def gdrive_upload_file(
self,
parent_id,
title,
no_progress_bar=True,
no_progress_bar=False,
from_file="",
progress_name="",
):
Expand Down
6 changes: 3 additions & 3 deletions dvc/remote/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _upload_to_bucket(
to_info,
chunk_size=None,
name=None,
no_progress_bar=True,
no_progress_bar=False,
):
blob = bucket.blob(to_info.path, chunk_size=chunk_size)
with io.open(from_file, mode="rb") as fobj:
Expand Down Expand Up @@ -167,7 +167,7 @@ def exists(self, path_info):
"""
return self.isfile(path_info) or self.isdir(path_info)

def _upload(self, from_file, to_info, name=None, no_progress_bar=True):
def _upload(self, from_file, to_info, name=None, no_progress_bar=False):
bucket = self.gs.bucket(to_info.bucket)
_upload_to_bucket(
bucket,
Expand All @@ -177,7 +177,7 @@ def _upload(self, from_file, to_info, name=None, no_progress_bar=True):
no_progress_bar=no_progress_bar,
)

def _download(self, from_info, to_file, name=None, no_progress_bar=True):
def _download(self, from_info, to_file, name=None, no_progress_bar=False):
bucket = self.gs.bucket(from_info.bucket)
blob = bucket.get_blob(from_info.path)
with io.open(to_file, mode="wb") as fobj:
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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:
Expand Down Expand Up @@ -102,7 +102,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(repo, outs=[out], add=True, fname=fname)
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down