mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-18 07:18:26 +01:00
add: fix progress bar on single target (#6288)
This commit is contained in:
+7
-4
@@ -51,7 +51,7 @@ class Tqdm(tqdm):
|
||||
file=None,
|
||||
total=None,
|
||||
postfix=None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
bytes : shortcut for
|
||||
@@ -90,7 +90,7 @@ class Tqdm(tqdm):
|
||||
bar_format="!",
|
||||
lock_args=(False,),
|
||||
total=total,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
self.postfix = postfix or {"info": ""}
|
||||
if bar_format is None:
|
||||
@@ -106,13 +106,16 @@ class Tqdm(tqdm):
|
||||
self.bar_format = bar_format
|
||||
self.refresh()
|
||||
|
||||
def update_msg(self, msg, n=1):
|
||||
def update_msg(self, msg: str, n: int = 1) -> None:
|
||||
"""
|
||||
Sets `msg` as a postfix and calls `update(n)`.
|
||||
"""
|
||||
self.postfix["info"] = " %s |" % msg
|
||||
self.set_msg(msg)
|
||||
self.update(n)
|
||||
|
||||
def set_msg(self, msg: str) -> None:
|
||||
self.postfix["info"] = f" {msg} |"
|
||||
|
||||
def update_to(self, current, total=None):
|
||||
if total:
|
||||
self.total = total
|
||||
|
||||
+5
-3
@@ -94,14 +94,16 @@ def translate_graph_error(stages: Stages) -> Iterator[None]:
|
||||
def progress_iter(stages: Stages) -> Iterator["Stage"]:
|
||||
total = len(stages)
|
||||
desc = "Adding..."
|
||||
with ui.progress(total=total, desc=desc, unit="file", leave=True) as pbar:
|
||||
with ui.progress(
|
||||
stages, total=total, desc=desc, unit="file", leave=True
|
||||
) as pbar:
|
||||
if total == 1:
|
||||
pbar.bar_format = desc
|
||||
pbar.refresh()
|
||||
|
||||
for stage in stages:
|
||||
for stage in pbar:
|
||||
if total > 1:
|
||||
pbar.update_msg(f"{stage.outs[0]}")
|
||||
pbar.set_msg(f"{stage.outs[0]}")
|
||||
yield stage
|
||||
if total == 1: # restore bar format for stats
|
||||
# pylint: disable=no-member
|
||||
|
||||
Reference in New Issue
Block a user