Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

progressbardistributed-2026.6.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

progressbardistributed-2026.6.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file progressbardistributed-2026.6.0.tar.gz.

File metadata

File hashes

Hashes for progressbardistributed-2026.6.0.tar.gz
Algorithm Hash digest
SHA256 6f39f0eaf7585d0a3c2fd0ca6f21d65d610e2c55b8e1405f25ee74c725dcef01
MD5 6769b1b430901690b6291e21b1f32fd0
BLAKE2b-256 6f0574d25ad1590b92179bfc9ce238d79af94837bb48bb3f6688ba445180a9f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for progressbardistributed-2026.6.0.tar.gz:

Publisher: publish-to-pypi.yml on rsanchezgarc/progressBarDistributed

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

File details

Details for the file progressbardistributed-2026.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for progressbardistributed-2026.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a8dfbff01313a9c5d68c6cd6c80b1b86ed0d8803fa7d0f13de651a88e2f83d0
MD5 8d3c1d9cbf8f24d2f70eb3bfc66ed0cc
BLAKE2b-256 5b8433c9f1a43e2749f736076c37b338014852d9d3d5d1b8253658ba24ecc5e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for progressbardistributed-2026.6.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on rsanchezgarc/progressBarDistributed

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