Skip to main content

mmar-utils

Common pure/IO utilities for multi-modal architectures team.

Installation

pip install mmar-utils

parallel_map

Mix of joblib.Parallel and tqdm.

Similar libraries

joblib.Parallel: https://joblib.readthedocs.io/en/latest/parallel.html

  • doesn't support showing progress out of the box

Syntax comparison ( assuming tqdm disabled )

from math import sqrt, pow
from joblib import Parallel as P, delayed as d
from agi_med_utils import parallel_map

# ONE-ARG: THREADING
print(P(n_jobs=2)(map(d(sqrt), range(5))))
print(P(n_jobs=2)(d(sqrt)(i) for i in range(5)))
print(parallel_map(sqrt, range(5)))
# > [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]

# ONE-ARG: MULTIPROCESSING
print(P(n_jobs=2, backend='multiprocessing')(d(sqrt)(i) for i in range(3)))
print(parallel_map(sqrt, range(3), process=True))
# > [0.0, 1.0, 1.4142135623730951]

# MANY-ARGS: THREADING
pow_args = [(i, j) for i in range(1, 4) for j in range(1, 3)]
print(P(n_jobs=2)(d(pow)(i, j) for i, j in pow_args))
print(parallel_map(pow, pow_args, multiple_args=True))
# > [1.0, 1.0, 2.0, 4.0, 3.0, 9.0]

# KWARGS: THREADING
def ipow_kw(*, x, y):
    return 1 / pow(x, y)
ipow_kwargs = [{'x': i, 'y': j} for i, j in pow_args]
print(P(n_jobs=2)(d(ipow_kw)(**kw) for kw in ipow_kwargs))
print(parallel_map(ipow_kw, ipow_kwargs, kwargs_args=True))
# > [1.0, 1.0, 0.5, 0.25, 0.3333333333333333, 0.1111111111111111]

# KWARGS: MULTIPROCESSING
def ipow_kw_inc(*, x, y):
    return 1 / pow(x, y) + 1
print(P(n_jobs=2, backend='multiprocessing')(d(ipow_kw_inc)(**kw) for kw in ipow_kwargs))
print(parallel_map(ipow_kw_inc, ipow_kwargs, kwargs_args=True, process=True))
# > [2.0, 2.0, 1.5, 1.25, 1.3333333333333333, 1.1111111111111112]

pqdm: https://pqdm.readthedocs.io/en/latest/usage.html

trace_with

Decorator for function which executes some callback on each function call.

Similar libraries

functrace: https://github.com/idanhazan/functrace

  • does not remember start datetime of call, which is critical
  • supports selection of parameters to remember
  • functrace.TraceResult object is not serializable out of the box

Metadata

Release files for mmar-utils 1.1.21

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

Source distribution (sdist)

Source distribution for mmar-utils 1.1.21
File Size Uploaded Provenance Actions
mmar_utils-1.1.21.tar.gz 13.3 kB Without provenance Details for mmar_utils-1.1.21.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mmar-utils 1.1.21
File Interpreter ABI Platform Actions
mmar_utils-1.1.21-py3-none-any.whl Python 3 none any Details for mmar_utils-1.1.21-py3-none-any.whl

Total release size: 31.4 kB

Release files / mmar_utils-1.1.21.tar.gz

Download URL mmar_utils-1.1.21.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dcac3e83ad1f5b6a0462436c752cddc06e798d2f0b4cc74e861028e9294476b7
BLAKE2b-256 checksum
How to use checksums
a8af397a5c674eb348dd854e53e0961aa5b9afffbdb85bd512c3bd6424cec84d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.31

Release files / mmar_utils-1.1.21-py3-none-any.whl

Download URL mmar_utils-1.1.21-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1f25beb74229b3abbee19f60a674f02fdb77c4dcf9ba501d42afb86cc6bc216
BLAKE2b-256 checksum
How to use checksums
741193f3d0808b2bc9657bfd4bfa8c350003ecc27f2166cca10f09afb4d22af4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.31

Security for mmar-utils 1.1.21

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

1.1.21 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