Helpers for reporting a progress from functions by the means of callbacks.
Project description
Progress-checkpoint
Helpers for reporting a progress from functions by the means of callbacks.
Examples
Trivial
from progress_checkpoint import dummy_checkpoint, with_progress
def time_consuming_operation(checkpoint=dummy_checkpoint):
for i in with_progress(range(10), checkpoint):
time.sleep(0.2)
time_consuming_operation(lambda p, _: print("{:.0f}%% ready".format(p*100)))
Subcheckpoints
from progress_checkpoint import dummy_checkpoint, with_progress, with_progress_sub
def time_consuming_operation(checkpoint=dummy_checkpoint):
for _ in with_progress(range(10), checkpoint):
sleep(0.1)
def compound_time_consuming_operation(checkpoint=dummy_checkpoint):
for _, subcheckpoint in with_progress_sub(range(2), checkpoint):
time_consuming_operation(subcheckpoint)
compound_time_consuming_operation(lambda p, _: print("{:.0f}% ready".format(p * 100)))
Subcheckpoints with different weights
def time_consuming_operation(num, checkpoint=dummy_checkpoint):
for _ in with_progress(range(num), checkpoint):
sleep(0.1)
def compound_time_consuming_operation(checkpoint=dummy_checkpoint):
counts = [1, 3, 7]
for cnt, subcheckpoint in with_progress_sub(counts, checkpoint, weights=counts):
time_consuming_operation(cnt, subcheckpoint)
compound_time_consuming_operation(lambda p, _: print("{:.0f}% ready".format(p * 100)))
Reporting using progresssbar package
from progress_checkpoint.console import ProgressbarCheckpoint
def time_consuming_operation(checkpoint=dummy_checkpoint):
for _ in with_progress(range(10), checkpoint):
sleep(0.1)
time_consuming_operation(ProgressbarCheckpoint())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for progress_checkpoint-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83cefc3f1fa3dcf228b15af97fe4a80bf661b7156ae357aa54333ebf1a2e44c9 |
|
MD5 | 8e16732ad827e200da0cbca34a3886fd |
|
BLAKE2b-256 | 6292069c8c7acbcf2db3e9c7ab0294bc3dbb023c6a653b5b5e6e0dd83012aca3 |
Close
Hashes for progress_checkpoint-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cff49d3ca1b379e85e58ff1b0f7acad08047f4d9c17e8565e0d5c6a421380611 |
|
MD5 | 980f313b114f7ec91676b3b397ebc9d6 |
|
BLAKE2b-256 | d7b5a37915ceba523b92efb426824e5490fae57e89f9888e9132f31fedd3a9d0 |