⚡️ Introduction
multipipe is a Python utility that allows you to create pipelines of functions to execute on any given iterable (e.g., lists, generators) by leveraging multiprocessing. multipipe is built on top of multiprocess.
🔌 Requirements
python>=3.8
💾 Installation
pip install multipipe
💡 Examples
Basic usage
from multipipe import Multipipe
def add(x):
return x + 1
def mul(x):
return x * 2
pipe = Multipipe([ add, mul ])
pipe(range(10))
Output:
[ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 ]
Using partials
Sometimes, you may want to use partials to pass arguments to your functions.
from multipipe import Multipipe
from functools import partial
def add(x, y):
return x + y
def mul(x, y):
return x * y
pipe = Multipipe([ partial(add, y=1), partial(mul, y=2) ])
pipe(range(10))
Output:
[ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 ]
Complex IO pipeline
In this example, we lazily read data from a JSONl file, execute a pipeline of functions lazily, and write the results to a new JSONl file. In practice, this allows you to process huge files without loading their content into memory all-at-once.
from multipipe import Multipipe
from unified_io import read_jsonl, write_jsonl
# Create a pipeline of functions
pipe = Multipipe([ ... ])
# Read a JSONl file line-by-line as a generator, i.e., lazily
in_data = read_jsonl("path/to/input/file.jsonl", generator=True)
# This is still a generator.
# The pipeline will be executed lazily.
out_data = pipe(in_data, generator=True)
# Write a JSONl file from the generator executing the pipeline
write_jsonl(out_data, "path/to/output/file.jsonl")
🎁 Feature Requests
Would you like to see other features implemented? Please, open a feature request.
🤘 Want to contribute?
Would you like to contribute? Please, drop me an e-mail.
📄 License
multipipe is an open-sourced software licensed under the MIT license.
Metadata
Release files for multipipe 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| multipipe-0.1.0.tar.gz | 4.0 kB | Without provenance | Details for multipipe-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| multipipe-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for multipipe-0.1.0-py3-none-any.whl |
Total release size: 8.6 kB
Release files / multipipe-0.1.0.tar.gz
| Download URL | multipipe-0.1.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d939a8e38ae83ffb837faf4595f9ef411a3d90eb96a13b179f40ecdde6a6242
|
|
BLAKE2b-256 checksum How to use checksums |
9505b3f876e623a43d6f8247191df8b80750c737988dcd7006667857a426545d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.12
|
Release files / multipipe-0.1.0-py3-none-any.whl
| Download URL | multipipe-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b96a57941f3b833696323e9850841d0ec71b4b6e080e84972688e84f91d7dc5
|
|
BLAKE2b-256 checksum How to use checksums |
30c1e8e82b2b78c9b549faf2a8ff7c78f713cf2eaa7f7f59c09e6941f59f5bc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.12
|
Security for multipipe 0.1.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.