A package for batch processing with sync and async capabilities
Project description
batch_please
A flexible and efficient Python library for processing large datasets in batches, with support for both synchronous and asynchronous operations.
Features
- Process large datasets in customizable batch sizes
- Support for both synchronous and asynchronous processing
- Checkpoint functionality to resume processing from where it left off
- Optional progress bar using tqdm
- Configurable concurrency limit for asynchronous processing
- Logging support
Installation
pip install batch_please
Quick Start
Synchronous Processing
from batch_please import BatchProcessor
def process_func(item):
return f"Processed: {item}"
processor = BatchProcessor(
process_func=process_func,
batch_size=100,
use_tqdm=True
)
input_data = range(1000)
processed_items = processor.process_items_in_batches(input_data)
Asynchronous Processing
import asyncio
from batch_please import AsyncBatchProcessor
async def async_process_func(item):
await asyncio.sleep(0.1)
return f"Processed: {item}"
async def main():
processor = AsyncBatchProcessor(
process_func=async_process_func,
batch_size=100,
max_concurrent=10,
use_tqdm=True
)
input_data = range(1000)
processed_items = await processor.process_items_in_batches(input_data)
asyncio.run(main())
Advanced Usage
Checkpoint Recovery
processor = BatchProcessor(
process_func=process_func,
batch_size=100,
pickle_file="checkpoint.pkl",
recover_from_checkpoint=True
)
Logging
processor = BatchProcessor(
process_func=process_func,
batch_size=100,
logfile="processing.log"
)
Further Documentation
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file batch_please-0.1.5.tar.gz.
File metadata
- Download URL: batch_please-0.1.5.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd10a4c5f2af7465cba5b3a44974b54c696b63e643b5b90a50e6a42bef03c4e4
|
|
| MD5 |
f75f03624e5a18e9fde25409c5e6fef0
|
|
| BLAKE2b-256 |
132ea331856b59bced651613d811b1f80b3192830d4f1f8dce4294b078e1a1f8
|
Provenance
The following attestation bundles were made for batch_please-0.1.5.tar.gz:
Publisher:
release.yml on gillespied/batch_please
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
batch_please-0.1.5.tar.gz -
Subject digest:
bd10a4c5f2af7465cba5b3a44974b54c696b63e643b5b90a50e6a42bef03c4e4 - Sigstore transparency entry: 153056823
- Sigstore integration time:
-
Permalink:
gillespied/batch_please@da65a3bf055876f9b370a9d30dfe75bd5f4b8f60 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/gillespied
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@da65a3bf055876f9b370a9d30dfe75bd5f4b8f60 -
Trigger Event:
push
-
Statement type:
File details
Details for the file batch_please-0.1.5-py3-none-any.whl.
File metadata
- Download URL: batch_please-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a3d95da36f8b4e7c3170eaea3ebb256b4a8098e9f0ed059d4394079fbb115d5
|
|
| MD5 |
99a3bd43311bbaf1104a0b05a5dd79a1
|
|
| BLAKE2b-256 |
645c60e99841f08d677a306d2cef7d3f65f9315f1e2a2a24adbd3b0b5c9956f8
|
Provenance
The following attestation bundles were made for batch_please-0.1.5-py3-none-any.whl:
Publisher:
release.yml on gillespied/batch_please
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
batch_please-0.1.5-py3-none-any.whl -
Subject digest:
7a3d95da36f8b4e7c3170eaea3ebb256b4a8098e9f0ed059d4394079fbb115d5 - Sigstore transparency entry: 153056824
- Sigstore integration time:
-
Permalink:
gillespied/batch_please@da65a3bf055876f9b370a9d30dfe75bd5f4b8f60 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/gillespied
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@da65a3bf055876f9b370a9d30dfe75bd5f4b8f60 -
Trigger Event:
push
-
Statement type: