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.1.5.tar.gz (10.1 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.1.5-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

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

Hashes for batch_please-0.1.5.tar.gz
Algorithm Hash digest
SHA256 bd10a4c5f2af7465cba5b3a44974b54c696b63e643b5b90a50e6a42bef03c4e4
MD5 f75f03624e5a18e9fde25409c5e6fef0
BLAKE2b-256 132ea331856b59bced651613d811b1f80b3192830d4f1f8dce4294b078e1a1f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for batch_please-0.1.5.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.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

Hashes for batch_please-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7a3d95da36f8b4e7c3170eaea3ebb256b4a8098e9f0ed059d4394079fbb115d5
MD5 99a3bd43311bbaf1104a0b05a5dd79a1
BLAKE2b-256 645c60e99841f08d677a306d2cef7d3f65f9315f1e2a2a24adbd3b0b5c9956f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for batch_please-0.1.5-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