MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / TqdmUpTo

Class TqdmUpTo

monai/apps/utils.py:97–112  ·  view source on GitHub ↗

Provides `update_to(n)` which uses `tqdm.update(delta_n)`. Inspired by the example in https://github.com/tqdm/tqdm.

Source from the content-addressed store, hash-verified

95 if has_tqdm and progress:
96
97 class TqdmUpTo(tqdm):
98 """
99 Provides `update_to(n)` which uses `tqdm.update(delta_n)`.
100 Inspired by the example in https://github.com/tqdm/tqdm.
101 """
102
103 def update_to(self, b: int = 1, bsize: int = 1, tsize: int | None = None) -> None:
104 """
105 Args:
106 b: number of blocks transferred so far, default: 1.
107 bsize: size of each block (in tqdm units), default: 1.
108 tsize: total size (in tqdm units). if None, remains unchanged.
109 """
110 if tsize is not None:
111 self.total = tsize
112 self.update(b * bsize - self.n) # will also set self.n = b * bsize
113
114 with TqdmUpTo(unit="B", unit_scale=True, unit_divisor=1024, miniters=1, desc=_basename(filepath)) as t:
115 urlretrieve(url, filepath, reporthook=t.update_to)

Callers 1

_download_with_progressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…