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: make progress bars respect --quiet #3316

Merged
merged 5 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dvc/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _do_lock(self):
try:
with Tqdm(
bar_format="{desc}",
disable=not self._friendly,
disable=True if not self._friendly else None,
casperdcl marked this conversation as resolved.
Show resolved Hide resolved
desc=(
"If DVC froze, see `hardlink_lock` in {}".format(
format_link("man.dvc.org/config#core")
Expand Down
4 changes: 2 additions & 2 deletions dvc/remote/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def list_cache_paths(self):
return self._list_paths(self.path_info.bucket, self.path_info.path)

def _upload(
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs
self, from_file, to_info, name=None, no_progress_bar=None, **_kwargs
casperdcl marked this conversation as resolved.
Show resolved Hide resolved
):
with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
self.blob_service.create_blob_from_path(
Expand All @@ -119,7 +119,7 @@ def _upload(
)

def _download(
self, from_info, to_file, name=None, no_progress_bar=False, **_kwargs
self, from_info, to_file, name=None, no_progress_bar=None, **_kwargs
):
with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
self.blob_service.get_blob_to_path(
Expand Down
4 changes: 2 additions & 2 deletions dvc/remote/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def _handle_transfer_exception(
)
return 1

def upload(self, from_info, to_info, name=None, no_progress_bar=False):
def upload(self, from_info, to_info, name=None, no_progress_bar=None):
if not hasattr(self, "_upload"):
raise RemoteActionNotImplemented("upload", self.scheme)

Expand Down Expand Up @@ -593,7 +593,7 @@ def download(
from_info,
to_info,
name=None,
no_progress_bar=False,
no_progress_bar=None,
file_mode=None,
dir_mode=None,
):
Expand Down
2 changes: 1 addition & 1 deletion dvc/remote/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, repo, config):
"files. Use: `dvc remote modify <name> no_traverse true`"
)

def _download(self, from_info, to_file, name=None, no_progress_bar=False):
def _download(self, from_info, to_file, name=None, no_progress_bar=None):
response = self._request("GET", from_info.url, stream=True)
if response.status_code != 200:
raise HTTPError(response.status_code, response.reason)
Expand Down
4 changes: 2 additions & 2 deletions dvc/remote/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def cache_exists(self, checksums, jobs=None, name=None):
]

def _upload(
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs
self, from_file, to_info, name=None, no_progress_bar=None, **_kwargs
):
makedirs(to_info.parent, exist_ok=True)

Expand All @@ -240,7 +240,7 @@ def _upload(
os.rename(tmp_file, fspath_py35(to_info))

def _download(
self, from_info, to_file, name=None, no_progress_bar=False, **_kwargs
self, from_info, to_file, name=None, no_progress_bar=None, **_kwargs
):
copyfile(
from_info, to_file, no_progress_bar=no_progress_bar, name=name
Expand Down
4 changes: 2 additions & 2 deletions dvc/remote/oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ def list_cache_paths(self):
return self._list_paths(self.path_info.path)

def _upload(
self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs
self, from_file, to_info, name=None, no_progress_bar=None, **_kwargs
):
with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
self.oss_service.put_object_from_file(
to_info.path, from_file, progress_callback=pbar.update_to
)

def _download(
self, from_info, to_file, name=None, no_progress_bar=False, **_kwargs
self, from_info, to_file, name=None, no_progress_bar=None, **_kwargs
):
with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
self.oss_service.get_object_to_file(
Expand Down
4 changes: 2 additions & 2 deletions dvc/remote/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def isdir(self, path_info):
dir_path = path_info / ""
return bool(list(self._list_paths(dir_path, max_items=1)))

def _upload(self, from_file, to_info, name=None, no_progress_bar=False):
def _upload(self, from_file, to_info, name=None, no_progress_bar=None):
total = os.path.getsize(from_file)
with Tqdm(
disable=no_progress_bar, total=total, bytes=True, desc=name
Expand All @@ -280,7 +280,7 @@ def _upload(self, from_file, to_info, name=None, no_progress_bar=False):
ExtraArgs=self.extra_args,
)

def _download(self, from_info, to_file, name=None, no_progress_bar=False):
def _download(self, from_info, to_file, name=None, no_progress_bar=None):
if no_progress_bar:
total = None
else:
Expand Down
4 changes: 2 additions & 2 deletions dvc/remote/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def move(self, from_info, to_info):
with self.ssh(from_info) as ssh:
ssh.move(from_info.path, to_info.path)

def _download(self, from_info, to_file, name=None, no_progress_bar=False):
def _download(self, from_info, to_file, name=None, no_progress_bar=None):
assert from_info.isin(self.path_info)
with self.ssh(self.path_info) as ssh:
ssh.download(
Expand All @@ -235,7 +235,7 @@ def _download(self, from_info, to_file, name=None, no_progress_bar=False):
no_progress_bar=no_progress_bar,
)

def _upload(self, from_file, to_info, name=None, no_progress_bar=False):
def _upload(self, from_file, to_info, name=None, no_progress_bar=None):
assert to_info.isin(self.path_info)
with self.ssh(self.path_info) as ssh:
ssh.upload(
Expand Down
4 changes: 2 additions & 2 deletions dvc/remote/ssh/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def remove(self, path):
else:
self._remove_file(path)

def download(self, src, dest, no_progress_bar=False, progress_title=None):
def download(self, src, dest, no_progress_bar=None, progress_title=None):
with Tqdm(
desc=progress_title or os.path.basename(src),
disable=no_progress_bar,
Expand Down Expand Up @@ -202,7 +202,7 @@ def atomic_copy(self, src, dst):
finally:
self.remove(tmp)

def upload(self, src, dest, no_progress_bar=False, progress_title=None):
def upload(self, src, dest, no_progress_bar=None, progress_title=None):
self.makedirs(posixpath.dirname(dest))
tmp_file = tmp_fname(dest)
if not progress_title:
Expand Down
5 changes: 4 additions & 1 deletion dvc/repo/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ def _checkout(
logger.info("Nothing to do")
failed = []
with Tqdm(
total=total, unit="file", desc="Checkout", disable=total == 0
total=total,
unit="file",
desc="Checkout",
disable=True if total == 0 else None,
) as pbar:
for stage, filter_info in pairs:
failed.extend(
Expand Down
2 changes: 1 addition & 1 deletion dvc/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def makedirs(path, exist_ok=False, mode=None):
os.umask(umask)


def copyfile(src, dest, no_progress_bar=False, name=None):
def copyfile(src, dest, no_progress_bar=None, name=None):
"""Copy file with progress bar"""
from dvc.exceptions import DvcException
from dvc.progress import Tqdm
Expand Down