A distributed progress bar
Project description
progressBarDistributed
progressBarDistributed is a Python library that provides a tqdm-based progress bar for distributed tasks using shared memory. It allows you to track the progress of multiple workers across different processes.
Features
- Distributed progress tracking using shared memory
- Compatible with multiprocessing and joblib parallel processing
- Customizable progress bar display using tqdm
Installation
To install SharedMemoryProgressBar, you can use pip:
pip install .
Usage
Usage multiprocessing
Here's a basic example of how to use SharedMemoryProgressBar using multiprocessing
import multiprocessing
def _multiprocessing_worker(worker_id, steps, shm_name):
import time
from progressBarDistributed import SharedMemoryProgressBarWorker
with SharedMemoryProgressBarWorker(worker_id, shm_name) as pbar:
pbar.set_total_steps(steps)
for _ in range(steps):
time.sleep(0.1)
pbar.update(1)
raise NotImplementedError()
def main(n_jobs):
from progressBarDistributed import SharedMemoryProgressBar
import random
with SharedMemoryProgressBar(n_jobs) as pbar:
shm_name = pbar.shm_name
args_list = [(i, random.randint(10, 20), shm_name) for i in range(n_jobs)]
processes = []
for i in range(n_jobs):
p = multiprocessing.Process(target=_multiprocessing_worker, args=args_list[i])
p.start()
processes.append(p)
for p in processes:
p.join()
if __name__ == "__main__":
main(4)
Usage subprocess
Here's a basic example of how to use SharedMemoryProgressBar using subprocesses
### worker.py
import sys, os
import random
import time
from progressBarDistributed import SharedMemoryProgressBarWorker
def compute_steps():
random.randint(0, 1000)
if __name__ == "__main__":
shm_name = sys.argv[1]
worker_id = int(os.environ.get("PROGRESS_BAR_WORKER_ID"))
steps = compute_steps() #Compute the number of steps that this worker is going to do
with SharedMemoryProgressBarWorker(worker_id, shm_name) as pbar:
pbar.set_total_steps(steps)
for _ in range(steps):
time.sleep(0.1)
pbar.update(1)
### END OF worker.py
### main.py
from subprocess import Popen
from progressBarDistributed import SharedMemoryProgressBar
def main(n_jobs):
processes = []
with SharedMemoryProgressBar(n_jobs) as pbar:
for i in range(n_jobs):
env = os.environ.copy()
env["PROGRESS_BAR_WORKER_ID"] = str(i)
cmd = [sys.executable, "worker.py", pbar.shm_name]
print(cmd)
p = Popen(cmd, universal_newlines=True, shell=False, env=env)
processes.append(p)
# Wait for the processes to finish
for i, p in enumerate(processes):
out, err = p.communicate()
if __name__ == "__main__":
main(4)
### END OF main.py
API Reference
SharedMemoryProgressBar
__init__(n_workers, shm_name=None): Initialize the progress bar
get_worker(worker_id, shm_name): Get a worker instance
close(): Clean up resources
SharedMemoryProgressBarWorker
update(n=1): Update progress set_total_steps(n): Set the total number of steps for the worker
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 progressbardistributed-2026.6.0.tar.gz.
File metadata
- Download URL: progressbardistributed-2026.6.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f39f0eaf7585d0a3c2fd0ca6f21d65d610e2c55b8e1405f25ee74c725dcef01
|
|
| MD5 |
6769b1b430901690b6291e21b1f32fd0
|
|
| BLAKE2b-256 |
6f0574d25ad1590b92179bfc9ce238d79af94837bb48bb3f6688ba445180a9f0
|
Provenance
The following attestation bundles were made for progressbardistributed-2026.6.0.tar.gz:
Publisher:
publish-to-pypi.yml on rsanchezgarc/progressBarDistributed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
progressbardistributed-2026.6.0.tar.gz -
Subject digest:
6f39f0eaf7585d0a3c2fd0ca6f21d65d610e2c55b8e1405f25ee74c725dcef01 - Sigstore transparency entry: 1725938637
- Sigstore integration time:
-
Permalink:
rsanchezgarc/progressBarDistributed@19ff5944b3f486847735f1bfe98ddf43252bf7f0 -
Branch / Tag:
refs/tags/v2026.6.0 - Owner: https://github.com/rsanchezgarc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@19ff5944b3f486847735f1bfe98ddf43252bf7f0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file progressbardistributed-2026.6.0-py3-none-any.whl.
File metadata
- Download URL: progressbardistributed-2026.6.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a8dfbff01313a9c5d68c6cd6c80b1b86ed0d8803fa7d0f13de651a88e2f83d0
|
|
| MD5 |
8d3c1d9cbf8f24d2f70eb3bfc66ed0cc
|
|
| BLAKE2b-256 |
5b8433c9f1a43e2749f736076c37b338014852d9d3d5d1b8253658ba24ecc5e2
|
Provenance
The following attestation bundles were made for progressbardistributed-2026.6.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on rsanchezgarc/progressBarDistributed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
progressbardistributed-2026.6.0-py3-none-any.whl -
Subject digest:
9a8dfbff01313a9c5d68c6cd6c80b1b86ed0d8803fa7d0f13de651a88e2f83d0 - Sigstore transparency entry: 1725938766
- Sigstore integration time:
-
Permalink:
rsanchezgarc/progressBarDistributed@19ff5944b3f486847735f1bfe98ddf43252bf7f0 -
Branch / Tag:
refs/tags/v2026.6.0 - Owner: https://github.com/rsanchezgarc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@19ff5944b3f486847735f1bfe98ddf43252bf7f0 -
Trigger Event:
push
-
Statement type: