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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e33cf4c754196a6511b01eb627499d1f4e1f2f6353d310bc73bed80737a8ec84 |
|
MD5 | f107c68dd095f1012e8c28e30cf7ff50 |
|
BLAKE2b-256 | bd1cb33b2558d0839230b2687947e3b1f04ed47bf2377242ad0d87a92ddff46b |
Close
Hashes for progress_checkpoint-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 524ef7ccffa2756265a0008f57a3ccf77b302cceb7bad4a715b72df859670f55 |
|
MD5 | 3c9c807425179ea6f2a838f1b934ae6d |
|
BLAKE2b-256 | 04e8e9182c99c6c2ab8375895c3852c4b366beb282f92dcf3e99e99441e3b591 |