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
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06ff0dbfe27b11c84e9d5d9dd1038e89ce9b86e6f43d9db83bb0e91fee804d1e
|
|
| MD5 |
2461ec8fbcc4415ca470d673fe7cb098
|
|
| BLAKE2b-256 |
716a6479dd05ff36c782dbf9dd981c9fa550ce57024908ba16ca0ec60790c27f
|
Provenance
The following attestation bundles were made for tqdm_tag-0.2.8.tar.gz:
Publisher:
publish.yml on ColinMoldenhauer/tqdm-tag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tqdm_tag-0.2.8.tar.gz -
Subject digest:
06ff0dbfe27b11c84e9d5d9dd1038e89ce9b86e6f43d9db83bb0e91fee804d1e - Sigstore transparency entry: 835784542
- Sigstore integration time:
-
Permalink:
ColinMoldenhauer/tqdm-tag@780ed562e6ee90d6bceb99bd30d34486e7cf7f27 -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/ColinMoldenhauer
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@780ed562e6ee90d6bceb99bd30d34486e7cf7f27 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4add25af6009f77f94a98dfce85223def49b6f087c1599435a82a62df6ab983b
|
|
| MD5 |
f14e0b966d3c23b0042468463d8d5363
|
|
| BLAKE2b-256 |
5157b79d95a5343150226c5a605870308f7623df8922bffeeea9bc6964c513f3
|
Provenance
The following attestation bundles were made for tqdm_tag-0.2.8-py3-none-any.whl:
Publisher:
publish.yml on ColinMoldenhauer/tqdm-tag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tqdm_tag-0.2.8-py3-none-any.whl -
Subject digest:
4add25af6009f77f94a98dfce85223def49b6f087c1599435a82a62df6ab983b - Sigstore transparency entry: 835784544
- Sigstore integration time:
-
Permalink:
ColinMoldenhauer/tqdm-tag@780ed562e6ee90d6bceb99bd30d34486e7cf7f27 -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/ColinMoldenhauer
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@780ed562e6ee90d6bceb99bd30d34486e7cf7f27 -
Trigger Event:
push
-
Statement type: