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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44116d82d3f3eea975c63742d82334ec83f20a7b19d28b51b1a32a89080f520d |
|
MD5 | d794bbfe3a5cc29fc39c0f4fb48d9903 |
|
BLAKE2b-256 | ef1fb7c90f2c59b01c53f6e471f7caedf952b128c0a82bb0609ca7ee8f5960c6 |
Close
Hashes for progress_checkpoint-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c586c566ac7bc8b86306c493429f0c36c5dda0d3d84d60a4e626e6e99ff75f13 |
|
MD5 | 2cd1a071a3ea538f5869cc004cdfa86b |
|
BLAKE2b-256 | 9399673fb2ee3a8adc5b2e7c88d07bf5fe92f8796626a558f537852886e4e920 |