Skip to main content

Helpers for reporting a progress from functions by the means of callbacks.

Project description

Check package with mypy

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.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

progress_checkpoint-1.0.4-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: progress_checkpoint-1.0.4.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for progress_checkpoint-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7f0aaf7d0dd5805b0c94508d500547b36204a65ea565fc0f16b11b208d9b00af
MD5 29df1e23173b56b674b98d3a1b2b307b
BLAKE2b-256 d031c07a0d41846e3d53214841d69c9d8842b87824f1d7433effb22379ba50f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: progress_checkpoint-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for progress_checkpoint-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3e7785c5f47679138a53c1b2c86a97f081d6bcc725c28bd555276317a03088c7
MD5 01d4f37dfb1c4caa154403cf3e76ef45
BLAKE2b-256 b9a2aad5160078095871050d6b1d5be0bfe7fc19f30445dc3aadaa6fe2dda6eb

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