PYPI PACKAGE AUDIT v0.1.0 Gesundes Paket

batchcall

Wiederaufnehmbare gleichzeitige Batch-Aufrufe mit adaptiver Parallelität und JSONL-Persistenz

PyPkgScore batchcall
Methodik & Kriterien ♥ Donate
685 / 1000
Schnellinstallation
pip install batchcall
1. Governance
50/200
2. PEP-Metadaten
200/200
3. Sicherheit
200/200
4. Doku & SEO
105/200
5. CI-Engineering
130/200
📣 Prüfung teilen: Teilen Sie diesen Bericht und die Vorschau in der aktuellen Sprache
Advertisement
PYPI-TELEMETRIE

Downloads & Community-Verbreitung

Letzte 30 Tage (ohne Spiegelserver)
Letzte 7 Tage
0
Letzte 30 Tage
0
Gesamt (180 Tage)
0
Metrik / Ökosystem Status / Wert Quelle
Downloads (30d / 180d) — PyPI Stats (without mirrors)
Trusted Publishing (PEP 740) ✓ Verified OIDC PyPI Integrity / Sigstore
Django Packages — djangopackages.org
PyTech / PyPkgScore 685 / 1000 PyPkgScore Engine

Gesundheits- & Engineering-Analyse (5 Säulen)

1. Governance & Community50 / 200 ▾
LICENSE✓ 50 pts
SECURITY.md✕ 0 pts
CONTRIBUTING.md✕ 0 pts
CODE_OF_CONDUCT.md✕ 0 pts
2. PEP-Metadaten & Paketierung200 / 200 ▾
Wheel (.whl)✓ 50 pts
pyproject.toml✓ 50 pts
Project URLs✓ 50 pts
Trove Classifiers✓ 50 pts
3. Sicherheit & Lieferkette200 / 200 ▾
Null CVEs (OSV)✓ 60 pts
Trusted Publishing (OIDC)✓ 50 pts
Snyk / Audit Link✓ 40 pts
HTTPS-Repository✓ 50 pts
4. Dokumentation, SEO & Ökosystem105 / 200 ▾
Strukturierte README✓ 60 pts
Read the Docs✕ 0 pts
Django Packages✕ 0 pts
Webseite / Fachartikel✓ 45 pts
5. Engineering, CI & Qualität130 / 200 ▾
Automatisierte Tests✓ 65 pts
GitHub Actions CI✓ 65 pts
CHANGELOG.md✕ 0 pts
Env & Lockfile (uv/rye/poetry/pdm/hatch)✕ 0 pts
Advertisement
README & DOCS

Offizielle Dokumentation & Nutzungsleitfaden — batchcall

PyPI Metadata v0.1.0
Vollständige Originaldokumentation anzeigen (Englisches README) ▾

BatchCall

A lightweight Python library for concurrent batch calls, with independent adaptive concurrency, round-based retries, JSONL persistence and resume support. No runtime dependencies. Python 3.9+.

Designed for LLM APIs, agents, workflows and other I/O-bound calls. Bring your own callable; BatchCall handles scheduling, not business logic.

中文文档

Installation

From PyPI (once the first release is published):

python -m pip install batchcall

Or from a local checkout:

python -m pip install .

Quick start

import json
from batchcall import run, StorageConfig

class MyCaller:
    concurrency = 10
    adaptive = True
    max_concurrency = 50

    def __call__(self, input_data: str) -> dict:
        # Replace this example with your thread-safe API call.
        return {"status": "success", "output": input_data}

caller = MyCaller()
data = {str(i): json.dumps({"query": f"Question {i}"}) for i in range(100)}
summary = run(data, caller, storage_config=StorageConfig(output_path="experiment.jsonl"))
print(summary)

Multiple callers

Each object represents an independent rate-limit unit. Callers must be interchangeable for the same workload. Store credentials in your own caller; do not commit secrets.

caller1 = MyCaller()
caller1.concurrency = 10
caller1.max_concurrency = 30
caller2 = MyCaller()
caller2.concurrency = 20
caller2.max_concurrency = 100

from batchcall import LogConfig, RetryConfig

run(data, [caller1, caller2],
    storage_config=StorageConfig(output_path="experiment.jsonl", save_every_n=50),
    retry_config=RetryConfig(max_retries=3),
    log_config=LogConfig(log_path="runtime.log"))

Caller protocol

A callable accepts one JSON string and returns a dict. The library does not parse or validate the business JSON inside the string.

Field Required Meaning
status Yes success, rate_limited (HTTP 429), or any other failure string
output Yes JSON string; may be None on failure
duration_s No Finite, nonnegative seconds; measured by BatchCall if omitted
error No Human-readable error or None

Regular exceptions and invalid return contracts become exception failures. All failures are retried. The caller must manage API timeouts, credentials, thread safety and classify HTTP 429 as rate_limited. Hidden SDK retries are not separately observed by BatchCall.

Optional caller attributes (read at the start of each run):

Attribute Default Meaning
name caller_0, etc. Unique name for logs and records
concurrency 10 Fixed or initial concurrency
adaptive False Enable adaptive concurrency
max_concurrency 50 Upper bound in adaptive mode
adjust_every_n 100 Completed attempts per adjustment window

Each caller independently adjusts its concurrency after a full window of completed attempts (including errors and retries). At most 1% rate-limited: increase by 1; over 5%: halve, rounding down; otherwise hold. The minimum is 1. Running calls are not cancelled. Configuration attributes are never modified. RPM is measured over the last 60 seconds of actual callable starts, not actively limited. One callable invocation counts as one attempt regardless of internal HTTP requests.

Configuration

run(data, callers, *, storage_config=None, retry_config=None, log_config=None) accepts one caller or a list/tuple. All configuration objects are optional.

Class Parameters (defaults)
StorageConfig output_path="results.jsonl", save_every_n=50, resume=True
RetryConfig max_retries=3 (additional rounds, after initial round 0)
LogConfig log_every_n=100, console=True, log_path=None

Logs include total and per-caller RPM, target concurrency, in-flight requests, progress, success/failure counts, 429s, average elapsed and persisted records. Event logs also cover round boundaries, adjustments and tail repair. Console logs go to stderr. No raw input/output or credentials are logged by the framework.

Persistence and resume

Each completed attempt is appended to JSONL, including failures and retries. A record has this shape:

{"id":"case_001","input":"{\"query\":\"hello\"}","output":"{\"answer\":\"hi\"}","status":"success","elapsed":0.123,"error_msg":null,"caller_name":"caller_0","round":0}

output is the caller's business response string (or null on failure), status is the attempt status, and elapsed is its duration in seconds. All three are top-level fields. The caller protocol is unchanged.

Format change: Older JSONL records with nested output.response, output.status and output.elapsed are not supported. Use a new output file or migrate the old records before reading or resuming. This applies even with resume=False.

The main thread flushes every save_every_n completions and at round boundaries and exit. The initial round runs all pending IDs; later rounds run only failures from the previous round. Each run gets its own retry budget. Caller concurrency state persists across rounds, not across runs.

On startup, BatchCall scans the history line by line, keeping only successful IDs. Any ID that succeeded at least once is skipped when resume=True. A valid last record without a newline is preserved and given a newline; an invalid, unterminated last line is truncated. Other invalid lines or structurally invalid records raise an error. resume=False still appends and checks the file.

Use a new file or new IDs whenever input, model, or experiment settings change. Do not write to the same result file from multiple processes/runs. Flush is not fsync: a crash can lose unflushed or OS-buffered records. Calls may be repeated after a crash; this is not exactly-once execution. Side-effecting calls should be idempotent. Ordinary interruption flushes collected results where possible; running threads cannot be forcibly stopped, so set caller timeouts. Results can contain sensitive data: choose an appropriate storage location.

from batchcall import load_success_ids, iter_results

success_ids = load_success_ids("experiment.jsonl")
for record in iter_results("experiment.jsonl"):
    if record["status"] == "success":
        pass  # process a single successful record

The readers never modify files; iter_results yields every attempt, not deduplicated final results. load_success_ids returns an empty set for a missing file. Both reject corrupt records. Memory is bounded by input data, task IDs, active futures, the recent RPM window and the write buffer, not by the full historical result payloads.

run returns a dict with total, skipped, executed, success, failed, attempts, rate_limited, elapsed and output_path. Success/failure counts refer only to the current run's pending IDs.

Development

python -m pip install -e .
python -m unittest discover -s tests -v

MIT license.