Yet another batch processor. Small python module to do batch processing. Use this when you want something lightweight and quick to setup. For usecases when writing batch processing boilerplate code is too repetitive and boring and Apache Beam/Ray is overkill
Project description
Batch Processor Module
This module provides functionality for processing data in batches with options for progress tracking, retries, and saving results to a file. It includes a BatchProcessor class and a batch_processor_decorator for easy integration into your projects.
Usage
BatchProcessor Class
-
Import the BatchProcessor:
from batchprocessor import BatchProcessor
-
Define a function to process each batch:
def process_batch(batch): # Your processing logic here return {"processed": batch, "status": "success"}
-
Initialize the BatchProcessor:
processor = BatchProcessor( iterable=your_data, batch_size=5, progress=True, save_to_file="output.json", retries=2, retry_delay=1.0, )
-
Process the batches:
results = processor.process(process_batch) print("Final Results:", results)
batch_processor_decorator
-
Import the decorator:
from batchprocessor import batch_processor_decorator
-
Decorate your batch processing function:
@batch_processor_decorator( batch_size=5, progress=True, save_to_file="output_decorator.json", retries=2, retry_delay=1.0, ) def process_batch(batch): # Your processing logic here return {"processed": batch, "status": "success"}
-
Call the decorated function with your data:
process_batch(your_data)
Features
- Batch Processing: Process data in specified batch sizes.
- Progress Tracking: Optionally display a progress bar.
- Retries: Automatically retry failed batch processing with a specified delay.
- Save Results: Save batch results to a JSON file.
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 yabp-0.1.tar.gz.
File metadata
- Download URL: yabp-0.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a16b2e31fad7269ca5face4f6d235c2f59b4db42cf87bafd8345a74162fa233
|
|
| MD5 |
67553692b95809853f8821213c20e62c
|
|
| BLAKE2b-256 |
94e2b011e8527e0d54f5459dc5b831509a482355cafb5ba4ca55842411bda19c
|
File details
Details for the file yabp-0.1-py3-none-any.whl.
File metadata
- Download URL: yabp-0.1-py3-none-any.whl
- Upload date:
- Size: 2.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afa77b110e909f73afccff74ad1bd6bf8d2d05f08089a6e4c48830139dec9929
|
|
| MD5 |
583a1b3c6fab7cb7f79c5ff1f9dc3aa8
|
|
| BLAKE2b-256 |
9f89957b79f11238b0667a1d55d72c1282b1e8966e75e6091bdf2166b91e4d42
|