mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 15:28:34 +01:00
+12
-3
@@ -40,6 +40,10 @@ class Tqdm(tqdm):
|
||||
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}]"
|
||||
),
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
@@ -49,6 +53,7 @@ class Tqdm(tqdm):
|
||||
kwargs : anything accepted by `tqdm.tqdm()`
|
||||
"""
|
||||
kwargs = deepcopy(kwargs)
|
||||
kwargs.setdefault("unit_scale", True)
|
||||
if bytes:
|
||||
for k, v in dict(
|
||||
unit="B", unit_scale=True, unit_divisor=1024, miniters=1
|
||||
@@ -62,14 +67,18 @@ class Tqdm(tqdm):
|
||||
>= logging.CRITICAL
|
||||
)
|
||||
super(Tqdm, self).__init__(
|
||||
iterable=iterable, disable=disable, leave=leave, **kwargs
|
||||
iterable=iterable,
|
||||
disable=disable,
|
||||
leave=leave,
|
||||
bar_format=bar_format,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def update_desc(self, desc, n=1, truncate=True):
|
||||
"""
|
||||
Calls `set_description(truncate(desc))` and `update(n)`
|
||||
Calls `set_description_str(truncate(desc))` and `update(n)`
|
||||
"""
|
||||
self.set_description(
|
||||
self.set_description_str(
|
||||
self.truncate(desc) if truncate else desc, refresh=False
|
||||
)
|
||||
self.update(n)
|
||||
|
||||
+3
-1
@@ -638,7 +638,9 @@ class RemoteBASE(object):
|
||||
if not self.no_traverse:
|
||||
return list(set(checksums) & set(self.all()))
|
||||
|
||||
with Tqdm(total=len(checksums), unit="md5") as pbar:
|
||||
with Tqdm(
|
||||
desc="Querying remote cache", total=len(checksums), unit="md5"
|
||||
) as pbar:
|
||||
|
||||
def exists_with_progress(path_info):
|
||||
ret = self.exists(path_info)
|
||||
|
||||
@@ -254,7 +254,9 @@ class RemoteLOCAL(RemoteBASE):
|
||||
def cache_exists(self, checksums, jobs=None):
|
||||
return [
|
||||
checksum
|
||||
for checksum in Tqdm(checksums, unit="md5")
|
||||
for checksum in Tqdm(
|
||||
checksums, unit="md5", desc="Querying local cache"
|
||||
)
|
||||
if not self.changed_cache_file(checksum)
|
||||
]
|
||||
|
||||
@@ -319,7 +321,6 @@ class RemoteLOCAL(RemoteBASE):
|
||||
ret = self._group(checksum_infos, show_checksums=show_checksums) or {}
|
||||
md5s = list(ret)
|
||||
|
||||
logger.info("Collecting information from local cache...")
|
||||
local_exists = self.cache_exists(md5s, jobs=jobs)
|
||||
|
||||
# This is a performance optimization. We can safely assume that,
|
||||
@@ -329,7 +330,6 @@ class RemoteLOCAL(RemoteBASE):
|
||||
if download and sorted(local_exists) == sorted(md5s):
|
||||
remote_exists = local_exists
|
||||
else:
|
||||
logger.info("Collecting information from remote cache...")
|
||||
remote_exists = list(remote.cache_exists(md5s, jobs=jobs))
|
||||
|
||||
self._fill_statuses(ret, local_exists, remote_exists)
|
||||
|
||||
@@ -267,7 +267,9 @@ class RemoteSSH(RemoteBASE):
|
||||
if not self.no_traverse:
|
||||
return list(set(checksums) & set(self.all()))
|
||||
|
||||
with Tqdm(total=len(checksums), unit="md5") as pbar:
|
||||
with Tqdm(
|
||||
desc="Querying remote cache", total=len(checksums), unit="md5"
|
||||
) as pbar:
|
||||
|
||||
def exists_with_progress(chunks):
|
||||
return self.batch_exists(chunks, callback=pbar.update_desc)
|
||||
@@ -278,5 +280,5 @@ class RemoteSSH(RemoteBASE):
|
||||
results = executor.map(exists_with_progress, chunks)
|
||||
in_remote = itertools.chain.from_iterable(results)
|
||||
ret = list(itertools.compress(checksums, in_remote))
|
||||
pbar.update_desc("", 0) # clear path name description
|
||||
pbar.set_description_str("Querying remote cache")
|
||||
return ret
|
||||
|
||||
@@ -51,4 +51,4 @@ def checkout(self, target=None, with_deps=False, force=False, recursive=False):
|
||||
)
|
||||
|
||||
stage.checkout(force=force, progress_callback=pbar.update_desc)
|
||||
pbar.update_desc("Checkout", 0) # clear path name description
|
||||
pbar.set_description_str("Checkout")
|
||||
|
||||
Reference in New Issue
Block a user