tqdm-publisher
tqdm_publisher is a small Python package that allows you to subscribe to updates from tqdm progress bars with arbitrary callback functions.
This is useful if you want to use tqdm to track the progress of a long-running task, but you also want to do something else with the progress information (e.g., forward it to a user interface, log it to a file, etc.).
Installation
pip install tqdm_publisher
Getting Started
Basic Usage
To monitor the progress of an existing tqdm progress bar, simply swap the tqdmand TQDMPublisher constructors. Then, declare a callback function to handle progress updates, and subscribe it to the TQDMPublisher updates using the subscribe method before iteration begins.
Original Code
import random
import time
from tqdm import tqdm
N_TASKS = 100
# Create a list of tasks
durations = [ random.uniform(0, 1.0) for _ in range(N_TASKS) ]
# Create a progress bar
progress_bar = tqdm(durations)
# Iterate over the progress bar
for duration in progress_bar:
time.sleep(duration) # Execute the task
Modified Code
import random
import time
from tqdm_publisher import TQDMPublisher
N_TASKS = 100
durations = [ random.uniform(0, 1.0) for _ in range(N_TASKS) ]
progress_bar = TQDMPublisher(durations)
# Declare a callback function to handle progress updates
on_update = lambda info: print('Progress Update', info)
# Subscribe the callback to the TQDMPublisher
progress_bar.subscribe(on_update)
for duration in progress_bar:
time.sleep(duration)
Demo
A complete demo of tqdm_publisher can be found in the demo directory, which shows how to forward progress updates from the same TQDMPublisher instance to multiple clients.
To run the demo, first install the dependencies:
pip install tqdm_publisher[demo]
Then, run the base CLI command to start the demo server and client:
tqdm_publisher demo
Note: Alternatively, you can run each part of the demo separately by running
tqdm_publisher demo --serverandtqdm_publisher demo --clientin separate terminals.
Finally, you can click the Create Progress Bar button to create a new TQDMPublisher instance, which will begin updating based on the TQDMPublisher instance in the Python script.
Metadata
Release files for tqdm-publisher 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tqdm_publisher-0.1.1.tar.gz | 22.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tqdm_publisher-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.2 kB
Release files / tqdm_publisher-0.1.1.tar.gz
| Download URL | tqdm_publisher-0.1.1.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a966153e222b26d5a312ad1c0b7cd2a61f585e7e7d7cc6e68104ef46f2558e3
|
|
BLAKE2b-256 checksum How to use checksums |
1ca5dedf07e40a1db3372db087bc166521e7f8408bd8a42f36e01a42fb14cffb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Release files / tqdm_publisher-0.1.1-py3-none-any.whl
| Download URL | tqdm_publisher-0.1.1-py3-none-any.whl |
|---|---|
| Size | 23.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85a9b7a4d04e704f1564f4256feec33677f0e96f364f75f77377eba98c3ac283
|
|
BLAKE2b-256 checksum How to use checksums |
54efb5ffc080f21ac4c352043f0c4cb02722631aab1fabd2179fb8d29d64902f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Security for tqdm-publisher 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.