Once
logging:log.info.once("this log msg will be only logged once")
- Progress Bar:
progress_bar = log.pb(100)
- Sticky Bottom Progress Bar: Default behavior!
- Logging and Porgress Bar work hand-in-hand with no conflict: logs are printed before the progress bar
# logs
log = LogBar.shared() # <-- single global log (optional), shared everywhere
log.info("super log!")
log.info.once("Show only once")
log.info.once("Show only once") # <-- not logged
# progress bar
pb = log.pb(100) # <-- pass in any iterable or int
for _ in pb:
time.sleep(0.1)
# advanced progress bar usage
# progress bar with fixed title
pb = log.pb(100).title("Super Bar:") # <-- set fixed title
for _ in pb:
time.sleep(0.1)
# advanced progress bar usage
# progress bar with fixed title and dynamic sub_title
# dynamic title/sub_title requires manual calls to `draw()` show progress correctly in correct order
pb = log.pb(names_list).title("Processing Model").manual() # <-- switch to manual render mode: call `draw()` manually
for name in pb:
start = time.time()
log.info(f"{name} is about to be worked on...") # <-- logs and progress bar do not conflict
pb.subtitle(f"Processing Module: {name}").draw()
log.info(f"{name} completed: took {time.time()-start} secs")
time.sleep(0.1)
Replacing tqdm
with logbar
is effortless and most time most pythonic and easier to use while being more powerful in the construction
Simple
# tqdm
sum = 0
for n in tqdm.tqdm(range(1000)):
sum += n
time.sleep(0.1)
# logbar
sum = 0
for n in log.pb(100,000):
sum += n
time.sleep(0.1)
Manul Update
# tqdm, manual update mode
with tqdm.tqdm(total=len(f.keys())) as pb:
for k in f.keys():
x = f.get_tensor(k)
tensors[k] = x.half()
del x
pb.update()
# manual render mode, call ui render manually in each step
with log.pb(f.keys()) as pb:
for k in pb:
x = f.get_tensor(k)
tensors[k] = x.half()
del x
pb.render()
- Multiple Active Progress Bars