progress-checkpoint 1.0.5

Last updated:

0 purchases

progress-checkpoint 1.0.5 Image
progress-checkpoint 1.0.5 Images
Add to Cart

Description:

progresscheckpoint 1.0.5

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())

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.