mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
disable old progress
This commit is contained in:
@@ -53,9 +53,6 @@ class ColorFormatter(logging.Formatter):
|
||||
)
|
||||
|
||||
def format(self, record):
|
||||
if self._is_visible(record):
|
||||
self._progress_aware()
|
||||
|
||||
if record.levelname == "INFO":
|
||||
return record.msg
|
||||
|
||||
@@ -146,14 +143,6 @@ class ColorFormatter(logging.Formatter):
|
||||
|
||||
return (exception, stack_trace)
|
||||
|
||||
def _progress_aware(self):
|
||||
"""Add a new line if progress bar hasn't finished"""
|
||||
from dvc.progress import progress
|
||||
|
||||
if not progress.is_finished:
|
||||
progress._print()
|
||||
progress.clearln()
|
||||
|
||||
|
||||
class LoggerHandler(logging.StreamHandler):
|
||||
def handleError(self, record):
|
||||
|
||||
+11
-27
@@ -40,10 +40,7 @@ class Progress(tqdm):
|
||||
TODO: remove this class.
|
||||
"""
|
||||
def __init__(self):
|
||||
super(Progress, self).__init__(
|
||||
total=0,
|
||||
disable=logging.getLogger(
|
||||
__name__).getEffectiveLevel() >= logging.CRITICAL)
|
||||
super(Progress, self).__init__(total=0, disable=True)
|
||||
self.set_lock(Lock())
|
||||
self._targets = {}
|
||||
self.clearln()
|
||||
@@ -58,39 +55,26 @@ class Progress(tqdm):
|
||||
return self.total == self.n
|
||||
|
||||
def clearln(self):
|
||||
self.display("")
|
||||
pass
|
||||
|
||||
def update_target(self, name, current, total, auto_finish=False):
|
||||
"""Updates progress bar for a specified target."""
|
||||
if name in self._targets:
|
||||
t = self._targets[name]
|
||||
else:
|
||||
with self.get_lock():
|
||||
# TODO: up to 10 nested bars
|
||||
position = 1 + self._get_free_pos(self) % 10
|
||||
t = tqdm(
|
||||
total=total,
|
||||
desc=name,
|
||||
leave=False,
|
||||
position=position)
|
||||
self._targets[name] = t
|
||||
self.total += 1
|
||||
|
||||
t.update(current - t.n)
|
||||
if auto_finish and t.n == t.total:
|
||||
if total and self.total != total:
|
||||
self.set_n_total(total)
|
||||
self.set_postfix_str(name, refresh=False)
|
||||
self.update(current - self.n)
|
||||
if auto_finish and self.is_finished:
|
||||
self.finish_target(name)
|
||||
|
||||
def finish_target(self, name):
|
||||
"""Finishes progress bar for a specified target."""
|
||||
t = self._targets.pop(name)
|
||||
t.close()
|
||||
# TODO: We have to write a msg about finished target
|
||||
if self.total < 100:
|
||||
# only if less that 100 items
|
||||
print(t)
|
||||
self.update()
|
||||
self.set_postfix_str(name, refresh=False)
|
||||
self.clearln()
|
||||
|
||||
def __call__(self, seq, name="", total=None):
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning("DeprecationWarning: create Tqdm() instance instead")
|
||||
if total is None:
|
||||
total = len(seq)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from dvc.progress import progress, ProgressCallback
|
||||
|
||||
def test_quiet(caplog, capsys):
|
||||
with caplog.at_level(logging.CRITICAL, logger="dvc"):
|
||||
progress._print("something")
|
||||
progress.clearln()
|
||||
assert capsys.readouterr().out == ""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user