Skip to main content

Enhance tqdm progress bars by assigning tags and colors to iterations.

Project description

tqdm-tag

Enhance tqdm progress bars by assigning tags and colors to iterations.

Usage

tqdm-tag works as a drop-in replacement for tqdm. When initialized

Example 1: Define tags during initialization

from tqdm_tag import TqdmTag

pbar = TqdmTag(
    range(100),   # your iterable
    tag_to_status={"warn": 1, "error": 2},
    tag_to_color={"warn": "yellow", "error": "red"},
)
for i in pbar:
    if i == 1: pbar.tag("warn")
    if i == 90: pbar.tag("error")

Example 2: Set tags during processing

from tqdm_tag import TqdmTag

pbar = TqdmTag(range(100))     # initialize without pre-defined tags
for i in pbar:
    if i == 1: pbar.tag("warn", "yellow")   # add new tag (and color)
    if i == 30: pbar.tag("warn")            # reuse tag
    if i == 90: pbar.tag("error", "red")    # another tag (with custom status)

Example 3: Change color upon completion

import time
from tqdm_tag import TqdmTag

it = range(100)
pbar = TqdmTag(
    it,
    colour="red",
)
for i in pbar:
    time.sleep(.01)
    if i == len(it)-1: pbar.tag("default", "green")

Example 4: Use a pre-defined error class (equivalent to example 1)

from tqdm_tag import TqdmErrorTag

pbar = TqdmErrorTag(range(100))
for i in pbar:
    if i == 1: pbar.warn()
    if i == 30: pbar.error(color="red")

Advanced examples

Example 5: Handle multiple tags per progress bin

from tqdm_tag import TqdmTag

pbar = TqdmTag(
    range(100),
    reduce_op=max,  # use highest status value
)
for i in pbar:
    if i == 1: pbar.tag("tag1", status=1, color="green")
    if i == 2: pbar.tag("tag2", status=2, color="red")

pbar = TqdmTag(
    range(100),
    reduce_op=min,  # use lowest status value
    reduce_ignore_default=True,
)
for i in pbar:
    if i == 1: pbar.tag("tag1", status=1, color="green")
    if i == 2: pbar.tag("tag2", status=2, color="red")

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

tqdm_tag-0.2.8.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tqdm_tag-0.2.8-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file tqdm_tag-0.2.8.tar.gz.

File metadata

  • Download URL: tqdm_tag-0.2.8.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tqdm_tag-0.2.8.tar.gz
Algorithm Hash digest
SHA256 06ff0dbfe27b11c84e9d5d9dd1038e89ce9b86e6f43d9db83bb0e91fee804d1e
MD5 2461ec8fbcc4415ca470d673fe7cb098
BLAKE2b-256 716a6479dd05ff36c782dbf9dd981c9fa550ce57024908ba16ca0ec60790c27f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tqdm_tag-0.2.8.tar.gz:

Publisher: publish.yml on ColinMoldenhauer/tqdm-tag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tqdm_tag-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: tqdm_tag-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tqdm_tag-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4add25af6009f77f94a98dfce85223def49b6f087c1599435a82a62df6ab983b
MD5 f14e0b966d3c23b0042468463d8d5363
BLAKE2b-256 5157b79d95a5343150226c5a605870308f7623df8922bffeeea9bc6964c513f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tqdm_tag-0.2.8-py3-none-any.whl:

Publisher: publish.yml on ColinMoldenhauer/tqdm-tag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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