Skip to content

Commit

Permalink
fix unknown total progress
Browse files Browse the repository at this point in the history
- depends on tqdm/tqdm#800
  • Loading branch information
casperdcl committed Aug 26, 2019
1 parent c934275 commit 06f920d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions dvc/progress.py
Expand Up @@ -32,6 +32,11 @@ class Tqdm(tqdm):
"""
maximum-compatibility tqdm-based progressbars
"""
BAR_FMT_DEFAULT = (
"{percentage:3.0f}%|{bar:10}|{desc} {bar:-10b}{n}/{total}"
" [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}]"
)
BAR_FMT_NOTOTAL = "{desc} {bar:b}{n} [{elapsed}<??:??, {rate_fmt:>11}{postfix}]"

def __init__(
self,
Expand All @@ -40,10 +45,7 @@ def __init__(
bytes=False, # pylint: disable=W0622
desc_truncate=None,
leave=None,
bar_format=(
"{percentage:3.0f}%|{bar:10}|{desc} {bar:-10b}{n}/{total}"
" [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}]"
),
bar_format=None,
**kwargs
):
"""
Expand All @@ -66,6 +68,11 @@ def __init__(
logging.getLogger(__name__).getEffectiveLevel()
>= logging.CRITICAL
)
if bar_format is None:
if kwargs.get('total', getattr(iterable, '__len__', None)) is None:
bar_format = self.BAR_FMT_NOTOTAL
else:
bar_format = self.BAR_FMT_DEFAULT
super(Tqdm, self).__init__(
iterable=iterable,
disable=disable,
Expand Down

0 comments on commit 06f920d

Please sign in to comment.