Skip to content

Commit

Permalink
progress: persist primary description
Browse files Browse the repository at this point in the history
Move subsequent updates to a postfix.
Clear postfix on exit.
TODO: align nicely.
Fixes iterative#3681.
  • Loading branch information
casperdcl committed May 1, 2020
1 parent e553511 commit f8ac0d5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
9 changes: 3 additions & 6 deletions dvc/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def __init__(
kwargs.setdefault("unit_scale", total > 999 if total else True)
if file is None:
file = sys.stderr
self.desc_persist = desc
# auto-disable based on `logger.level`
if not disable:
disable = logger.getEffectiveLevel() > level
Expand Down Expand Up @@ -102,11 +101,11 @@ def __init__(
self.bar_format = bar_format
self.refresh()

def update_desc(self, desc, n=1):
def update_msg(self, msg, n=1):
"""
Calls `set_description_str(desc)` and `update(n)`
Calls `set_postfix_str(msg)` and `update(n)`
"""
self.set_description_str(desc, refresh=False)
self.set_postfix_str(msg, refresh=False)
self.update(n)

def update_to(self, current, total=None):
Expand All @@ -130,8 +129,6 @@ def wrapped(*args, **kwargs):
return wrapped

def close(self):
if self.desc_persist is not None:
self.set_description_str(self.desc_persist, refresh=False)
# unknown/zero ETA
self.bar_format = self.bar_format.replace("<{remaining}", "")
# remove completed bar
Expand Down
2 changes: 1 addition & 1 deletion dvc/remote/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ def _cache_object_exists(self, checksums, jobs=None, name=None):

def exists_with_progress(path_info):
ret = self.exists(path_info)
pbar.update_desc(str(path_info))
pbar.update_msg(str(path_info))
return ret

with ThreadPoolExecutor(max_workers=jobs or self.JOBS) as executor:
Expand Down
2 changes: 1 addition & 1 deletion dvc/remote/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def cache_exists(self, checksums, jobs=None, name=None):
) as pbar:

def exists_with_progress(chunks):
return self.batch_exists(chunks, callback=pbar.update_desc)
return self.batch_exists(chunks, callback=pbar.update_msg)

with ThreadPoolExecutor(max_workers=jobs or self.JOBS) as executor:
path_infos = [self.checksum_to_path_info(x) for x in checksums]
Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ def _create_stages(repo, targets, fname, pbar=None):

stages.append(stage)
if pbar is not None:
pbar.update_desc(out)
pbar.update_msg(out)

return stages
2 changes: 1 addition & 1 deletion dvc/repo/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _checkout(
for stage, filter_info in pairs:
result = stage.checkout(
force=force,
progress_callback=pbar.update_desc,
progress_callback=pbar.update_msg,
relink=relink,
filter_info=filter_info,
)
Expand Down

0 comments on commit f8ac0d5

Please sign in to comment.