Contents

Chapter 1

Features

This chapter covers the core features and capabilities of Batch Processor.

Features

  • Concurrent worker pool — ThreadPoolExecutor with a configurable max_workers limit
  • Configurable batch sizes — Split large item sets into fixed-size batches for controlled throughput
  • Retry with exponential backoff — Failed items are retried up to N times with increasing delays
  • Dead-letter queue — Items that exhaust all retries are captured with full error context for inspection
  • Transform pipeline — Chain cast, validate, map, rename, and enrich transforms in any order
  • Multiple input sources — Inline items in config, JSON files on disk, or generated demo data
  • Execution stats — Tracks submitted, succeeded, failed, dead-lettered, retries, and duration
  • Progress callbacks — Real-time per-item completion logging
  • JSON config support — Define complete jobs in a single config file for repeatable automation

Requirements

  • Python 3.10+
  • No external dependencies (stdlib only)
Chapter 2

Quick Start

Follow this guide to get Batch Processor up and running in your environment.

Quick Start

bash
# Show all available options
python src/batch_processor.py --help

# Run the example job (processes 8 inline orders, 2 will fail validation)
python src/batch_processor.py --config examples/batch_processor_config.json

# Override workers and batch size from the CLI
python src/batch_processor.py --config examples/batch_processor_config.json --workers 4 --batch-size 5

# Save stats to a file
python src/batch_processor.py --config examples/batch_processor_config.json --stats-file run_stats.json

# Verbose debug logging (shows every retry attempt)
python src/batch_processor.py --config examples/batch_processor_config.json --log-level DEBUG

Configuration Reference

Define complete batch jobs in a JSON config file:

json
{
    "name": "job_name",
    "source": {
        "type": "inline | json_file | generated",
        "id_field": "order_id",
        "items": [{"order_id": "ORD-1", "amount": "49.99"}]
    },
    "transforms": [
        {"type": "cast",          "field": "amount",  "to": "float"},
        {"type": "validate",      "field": "amount",  "op": "gt", "value": 0},
        {"type": "map",           "field": "name",    "operation": "upper"},
        {"type": "rename",        "field_map": {"old": "new"}},
        {"type": "add_field",     "field": "source",  "value": "batch_v1"},
        {"type": "add_timestamp", "field": "processed_at"}
    ],
    "batch_size": 10,
    "max_workers": 4,
    "retry": {
        "max_attempts": 3,
        "base_delay": 0.5,
        "backoff_factor": 2.0
    }
}

CLI Options

FlagDefaultDescription
--config, -c*(required)*Batch job config file (JSON)
--workers, -w4Max concurrent workers (overrides config)
--batch-size, -b10Items per batch (overrides config)
--stats-file—Write execution stats JSON to this file
--log-levelINFOLogging level (DEBUG, INFO, WARNING, ERROR)

Transform Types

TypeDescriptionConfig Fields
castCast a field to int/float/str/boolfield, to
validateFail the item if condition is not metfield, op, value
mapString operation (upper/lower/strip/title/hash_md5)field, operation
renameRename fields by mappingfield_map (dict)
add_fieldAdd a static key-value pairfield, value
add_timestampAdd a UTC ISO-8601 timestampfield (default: processed_at)
Chapter 3
🔒 Available in full product

Output

Chapter 4
🔒 Available in full product

04_License

You’ve reached the end of the free preview

Get the full Batch Processor and unlock everything.

All Chapters

Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.

Full Tool Suite

Access all interactive tools with complete data, all workload profiles, and the full scenario library.

Source Files

Downloadable source code, configuration files, and working examples from every chapter.

Lifetime Updates

Free updates for life. Every new chapter, tool, and improvement included.

Buy Now — $29 →
📦 Free sample included — download another copy for the full product.
Batch Processor v1.0.0 — Free Preview