Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

batch_please-0.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

batch_please-0.2.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file batch_please-0.2.0.tar.gz.

File metadata

  • Download URL: batch_please-0.2.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for batch_please-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4fab15fc33f16140081f455ddc6c6da7ce6573a2989b01f48e31468eefd6af5e
MD5 950f3c8fc6e31da6fd4c1c941686972d
BLAKE2b-256 66ca669d3de133e833f4228f35c997dcdc902dcdf8da2830efa52590395bfbbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for batch_please-0.2.0.tar.gz:

Publisher: release.yml on gillespied/batch_please

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file batch_please-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: batch_please-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for batch_please-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec54026bf1d954d9bda0a6753433fed99a732ed6fbf57762b8c1c6358aa34914
MD5 e503b939764a9fc46433880ffd9e7ac1
BLAKE2b-256 d72079660d1e4435e9006b2416df1b1b01daf1ffa8128a60f0a47058260ed65f

See more details on using hashes here.

Provenance

The following attestation bundles were made for batch_please-0.2.0-py3-none-any.whl:

Publisher: release.yml on gillespied/batch_please

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page