Skip to main content

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

progress_checkpoint-1.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

progress_checkpoint-1.0.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file progress_checkpoint-1.0.1.tar.gz.

File metadata

  • Download URL: progress_checkpoint-1.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200917 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.11

File hashes

Hashes for progress_checkpoint-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1ceee15b2b199d84c8b6e562dcb2b8525896926caa40a73ec55a0e47f746371c
MD5 5ddba4ce8dda952e779122b00392d494
BLAKE2b-256 573107dec5523b6482341aff8b9ac4d0178bc9809a8101fb963407ca4684723b

See more details on using hashes here.

File details

Details for the file progress_checkpoint-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: progress_checkpoint-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200917 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.11

File hashes

Hashes for progress_checkpoint-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c85e2cc74cb24372db884d381301fc69dc354653eb1bd7d6b3b8163fdf1404f3
MD5 bcba0275ba559ba9a18c1d652e61f1cb
BLAKE2b-256 de54137be6f29863ad55f5950dac70c1c7fe267cf99992b6b6d6565196a95b06

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page