Skip to main content

parabar

Progress bars from tqdm for multiprocessing with pathos in Python.

This is similar in spirit to tqdm_pathos but more simplified.

Installation

pip install parabar

Usage

There is a single function parabar.map.

The two required arguments are the function you want to map and the iterable(s) you want to map over: parabar.map(func, iterable).

If you want to iterate over multiple arguments, you should zip them: parabar.map(func, zip(iterable1, iterable2)).

It has two optional arguments:

  • ncpus = 1: the number of processes for the pool
  • tqdm_kwargs = {}: dictionary of extra arguments to pass to tqdm.

If the length of your iterable is total, you can tell tqdm by using tqdm_kargs = {'total': total}. Otherwise, parabar.map will convert your iterables to a list and use len.

You can provide other fixed positional and keywords arguments to your function that you do not want to iterate over as the reminaing position and keyword arguments: parabar.map(func, iterable, arg1, arg2, kwarg1=None, ncpus=1).

Examples

Function of a single iterable:

f = lambda x: x**2
iterable = [1, 2, 3]

# Serial
y = [f(x) for x in iterable]
print(y)

# Parallel
y = parabar.map(f, iterable)
print(y)

Function of a single iterable, with non-iterable args and kwargs:

f = lambda x, a, b = 0: x**2 * a + b
iterable = [1, 2, 3]
a = 1
b = 0

# Serial
y = [f(x, a, b = b) for x in iterable]
print(y)

# Parallel
y = parabar.map(f, iterable, a, b = b)
print(y)

Function of multiple iterables:

f = lambda x, y: x * y
iterable1 = [1, 2, 3]
iterable2 = [4, 5, 6]

# Serial
z = [f(x, y) for x, y in zip(iterable1, iterable2)]
print(z)

# Parallel
z = parabar.map(f, zip(iterable1, iterable2))
print(z)

Function of multiple iterables, with non-iterable args and kwargs

f = lambda x, y, a, b = 0: x * y * a + b
iterable1 = [1, 2, 3]
iterable2 = [4, 5, 6]
a = 1
b = 0

# Serial
z = [f(x, y, a, b = b) for x, y in zip(iterable1, iterable2)]
print(z)

# Parallel
z = parabar.map(f, zip(iterable1, iterable2), a, b = b)
print(z)

Specify number of processes and keyword arguments for progress bar

from tqdm.auto import tqdm

f = lambda x: x
iterable = [1, 2, 3]
tqdm_kwargs = dict(total = 3, desc = 'iterating')

# Serial
y = [f(x) for x in tqdm(iterable, **tqdm_kwargs)]
print(y)

# Parallel
y = parabar.map(f, iterable, ncpus=2, tqdm_kwargs=tqdm_kwargs)
print(y)

Metadata

Release files for parabar 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for parabar 0.3.0
File Size Uploaded Provenance Actions
parabar-0.3.0.tar.gz 3.2 kB Without provenance Details for parabar-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for parabar 0.3.0
File Interpreter ABI Platform Actions
parabar-0.3.0-py3-none-any.whl Python 3 none any Details for parabar-0.3.0-py3-none-any.whl

Total release size: 6.6 kB

Release files / parabar-0.3.0.tar.gz

Download URL parabar-0.3.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d20dd1dff6dfcead5557e31b73ab3e87d2667d369f208dce891b901aa5797c27
BLAKE2b-256 checksum
How to use checksums
fdb404c0a60cab27951a1ffa80ec772266052dc43916062bcb186ddeac8022d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.13

Release files / parabar-0.3.0-py3-none-any.whl

Download URL parabar-0.3.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c1f8a7b892c5f344f303ca2ba9ea6e59ae1d1eb4ee21016baa5416fef613664
BLAKE2b-256 checksum
How to use checksums
b4787a86b33c4b844732bba6cfaf5da980da396dc525c4aa2bd4b16066ad8ebf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.13

Security for parabar 0.3.0

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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page