An pqdm-compatible (almost) extension that supports stateful worker pools with both sized and unsized iterables.
Project description
MultiTASKLite: A lightweight library for Python multitasking
This mtasklite
library is inspired by the simplicity of the great pqdm
library, but it improves upon pqdm
in several ways, in particular, by supporting object-based (stateful) workers, truly "lazy" iteration, and context managers (i.e., a support for with-statement
). Stateful workers are implemented using the cool concept of delayed initialization, which is effortlessly enabled by adding @delayed_init
decorator to a worker class definition.
This enables:
- Using different GPUs, models, or network connections in different workers.
- Efficient initialization of workers: If the worker needs to load a model (which often takes quite a bit of time), it will be done once (per process/thread) before processing input items.(examples/mtasklite_pqdm_spacy_tokenization_demo.ipynb) for an example.
- Logging and bookkeeping: Each worker is represented by an object that "lives" as long as we have items to process (data can be stored in the object attributes).
The mtasklite
package provides pqdm-compatibility wrappers, which can be used as a (nearly) drop-in replacement of pqdm
. For an overview of differences, and a list of features, please, refer to the documentation in the GitHub repository.
This library is replacing py_stateful_map
. The objective of this replacement to provide a more convenient and user-friendly interface as well as to fix several issues.
Credits
A huge shoutout to the creators for the multiprocess library, which is a drop-in replacement of the standard Python multiprocessing
library, which resolves various pickling issues that arise on non-Unix platforms (when a standard multiprocessing library is used). Thanks to their effort, mtasklite
works across Linux, Windows, and MacOS.
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
Built Distribution
File details
Details for the file mtasklite-0.3.2.tar.gz
.
File metadata
- Download URL: mtasklite-0.3.2.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f2cd7edacf6178ff294d57416345d558cd2c1e3962611ad1abd964f3dc55e9b |
|
MD5 | 8f235a7512e6a3a36c301b9923730504 |
|
BLAKE2b-256 | a24124e2312201e5e54e7ecdd7703a8ee924d612a8d00de6190e483c66c6faaa |
File details
Details for the file mtasklite-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: mtasklite-0.3.2-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a280d29e5cf291ee4e9fc52d0c6f7eaf7a92a8ea6ff6536fc3ed083c1675fc9b |
|
MD5 | 5f5a22b0343d189a2766c5260a3fd69e |
|
BLAKE2b-256 | 87b6a7bba73244e33ffa0a93a8737a3ba6f8b424de93fcf152ad251343ca53e9 |