Configuration¶
EnrichmentConfig controls every aspect of pipeline execution: concurrency, retries, caching, checkpointing, and batch settings. Pass it to pipeline.run():
from accrue import Pipeline, EnrichmentConfig
config = EnrichmentConfig(max_workers=20)
result = pipeline.run(data, config=config)
All fields¶
| Field | Default | Description |
|---|---|---|
max_tokens |
4000 |
Max LLM output tokens |
temperature |
0.2 |
LLM temperature (0.1--0.3 best for enrichment) |
max_workers |
10 |
Concurrent rows per step |
overwrite_fields |
False |
Overwrite existing field values in the DataFrame |
max_retries |
3 |
API error retry attempts (429, 500, timeouts) |
retry_base_delay |
1.0 |
Exponential backoff base in seconds |
on_error |
"continue" |
"continue" collects errors; "raise" fails fast |
log_level |
"INFO" |
Logging level |
enable_progress_bar |
True |
Show tqdm progress bar |
enable_caching |
True |
SQLite input-hash cache (set False for one-off runs) |
cache_ttl |
3600 |
Cache TTL in seconds |
cache_dir |
~/.cache/accrue |
Directory for cache.db ($XDG_CACHE_HOME/accrue when set) |
enable_checkpointing |
False |
Step-level crash recovery |
checkpoint_dir |
~/.local/state/accrue |
Checkpoint directory ($XDG_STATE_HOME/accrue when set) |
auto_resume |
True |
Auto-resume from checkpoint on re-run |
checkpoint_interval |
0 |
Save partial step progress every N rows (0 = disabled) |
batch_poll_interval |
60.0 |
Seconds between batch status checks |
batch_timeout |
86400.0 |
Max batch wait time (default 24h) |
batch_max_requests |
50000 |
Auto-chunk threshold for batch submissions |
batch_max_bytes |
None |
Byte threshold for batch submissions (None = provider default) |
Presets¶
Four factory methods cover common scenarios:
for_development()¶
Low concurrency, verbose logging, caching on. Safe for Tier 1 accounts.
for_production()¶
High concurrency with caching and checkpointing. For Tier 2+ accounts.
config = EnrichmentConfig.for_production()
# max_workers=30, enable_checkpointing=True, enable_caching=True,
# checkpoint_interval=100, max_retries=5
for_server()¶
Async server context (FastAPI, etc.). No progress bars, high concurrency.
config = EnrichmentConfig.for_server()
# max_workers=30, enable_progress_bar=False, max_retries=5, log_level="WARNING"
for_batch()¶
Cost-optimized for large datasets using the Batch API.
config = EnrichmentConfig.for_batch()
# max_workers=10, enable_caching=True, enable_checkpointing=True,
# batch_poll_interval=60.0, batch_timeout=86400.0, max_retries=5
Temperature and max_tokens resolution¶
Both temperature and max_tokens can be set at the step level or the config level. Resolution order:
- Step-level (
LLMStep(temperature=0.5)) -- highest priority. - Config-level (
EnrichmentConfig(temperature=0.3)) -- fallback. - Default (
0.2for temperature,4000for max_tokens) -- final fallback.
# Step-level takes precedence
LLMStep("creative",
fields={"tagline": "Write a catchy tagline"},
temperature=0.8, # This wins over config.temperature
)
Some models ignore temperature. The Claude 5 family and Claude Opus 4.7/4.8 removed the sampling parameters and reject an explicit temperature with a 400. The Anthropic adapter omits it for those models, so the resolved value above never reaches the API and the model samples at its own default of 1.0. If the dropped value was anything other than 1.0, a warning is logged once per pipeline run. See Providers -> Anthropic.
Concurrency tuning¶
The max_workers setting controls how many rows are processed concurrently within each step (via asyncio.Semaphore). Set it based on your provider's rate limits.
Limits depend on the provider, the model and your account's tier, so check your provider's limits page. As a guide, OpenAI's lowest paid tier allows 5,000 requests and 2M tokens a minute on gpt-6-luna, accrue's default (model page), which leaves room for max_workers=10 to 50. Raise it as your tier grows.
Setting max_workers too high for your tier results in 429 rate-limit errors. The retry logic handles these with exponential backoff, but throughput will be lower than using the right concurrency level.
Caching¶
Enable caching to skip redundant API calls. The cache key is derived from the input row data, field specs, model, prompts and other step settings (full list). Cached results are stored in a SQLite database at {cache_dir}/cache.db.
config = EnrichmentConfig(
enable_caching=True,
cache_ttl=7200, # 2 hours
cache_dir="./.accrue", # Directory for cache.db (default: ~/.cache/accrue)
)
Note: sources_field is excluded from the cache key, so changing it does not invalidate cached results. provider_kwargs is part of the key, so changing it re-runs the step.
Checkpointing¶
Checkpointing saves completed step results so that a crashed pipeline can resume without re-running earlier steps.
config = EnrichmentConfig(
enable_checkpointing=True,
checkpoint_dir="./checkpoints", # default: ~/.local/state/accrue
auto_resume=True, # Resume automatically on re-run
checkpoint_interval=100, # Save every 100 rows within a step
)
When auto_resume=True, the pipeline detects an existing checkpoint on re-run and skips already-completed steps. Set checkpoint_interval to a positive integer to save partial progress within long-running steps.
Logging¶
Accrue logs through the standard logging module and does not configure
handlers on import, so by default you see whatever your application already set
up. setup_logging() is a convenience for when you have not set anything up:
from accrue import setup_logging
setup_logging(level="DEBUG") # colored console output
setup_logging(level="INFO", format_type="json") # structured, one JSON object per line
| Parameter | Default | Meaning |
|---|---|---|
level |
"INFO" |
DEBUG, INFO, WARNING, ERROR, or CRITICAL |
format_type |
"console" |
"console" for colored human-readable output, "json" for structured logs |
include_timestamp |
True |
Include timestamps in console format (ignored for json) |
It configures the root logger and replaces any handlers already attached, so call it once at startup and don't call it from library code. If your application already configures logging, skip it entirely — accrue's loggers propagate normally.
Most of accrue's own diagnostics are WARNING and above (retry exhaustion,
rate-limit fallbacks, batch-cancel failures, dropped temperature, checkpoint
mismatches), so INFO is a reasonable default. DEBUG currently adds only
LLMStep._apply_defaults decisions — when a value matched a refusal pattern and
was replaced with the field default, and when it was kept because it is a
declared enum member. For run-level diagnosis reach for result.report() and
result.summary() rather than the log stream.
Validation¶
EnrichmentConfig validates all fields on construction:
temperaturemust be between 0.0 and 2.0.max_tokens,max_workers,batch_poll_interval,batch_timeout, andbatch_max_requestsmust be positive;batch_max_bytesmust be positive when set.max_retries,cache_ttl, andcheckpoint_intervalmust be non-negative.
Invalid values raise ValueError immediately.