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.20

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.20
File Size Uploaded Provenance Actions
mmar_utils-1.1.20.tar.gz 13.3 kB Without provenance Details for mmar_utils-1.1.20.tar.gz

Built distribution (wheel)

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

Total release size: 31.4 kB

Release files / mmar_utils-1.1.20.tar.gz

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

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

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

Security for mmar-utils 1.1.20

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.20 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