Configuration System¶
Reference for all Pynenc configuration options, sources, and resolution order.
Configuration Sources¶
Configuration values resolve from these sources in priority order (highest first):
Direct assignment in the config instance
Environment variables (
PYNENC__FIELD_NAMEorPYNENC__CLASS__FIELD_NAME)Configuration file specified by
PYNENC__FILEPATHenvironment variableConfiguration file path passed to
Pynenc(config_filepath=...)(YAML, TOML, or JSON)pyproject.tomlunder[tool.pynenc]Default values defined in the
ConfigField
Environment Variables¶
Two naming conventions are supported:
# Default for all config classes
PYNENC__FIELD_NAME="value"
# Specific to a config class
PYNENC__CONFIGPYNENC__FIELD_NAME="value"
The specific form takes precedence over the default form.
Configuration Files¶
pyproject.toml¶
[tool.pynenc]
app_id = "my_application"
orchestrator_cls = "RedisOrchestrator"
broker_cls = "RedisBroker"
state_backend_cls = "RedisStateBackend"
runner_cls = "MultiThreadRunner"
serializer_cls = "JsonPickleSerializer"
[tool.pynenc.orchestrator]
max_pending_seconds = 300
[tool.pynenc.runner]
min_threads = 2
max_threads = 8
[tool.pynenc.task]
running_concurrency = "task"
YAML¶
app_id: my_application
orchestrator_cls: RedisOrchestrator
orchestrator:
max_pending_seconds: 300
runner:
min_threads: 4
max_threads: 16
Load with:
from pynenc import Pynenc
app = Pynenc(config_filepath="/path/to/pynenc.yaml")
JSON¶
{
"app_id": "my_application",
"orchestrator_cls": "RedisOrchestrator"
}
ConfigPynenc Fields¶
Main application configuration (pynenc.conf.config_pynenc.ConfigPynenc).
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Application identifier |
|
|
|
Orchestrator implementation class name |
|
|
|
Trigger implementation class name |
|
|
|
Broker implementation class name |
|
|
|
State backend implementation class name |
|
|
|
Serializer implementation class name |
|
|
|
Client data store implementation class name |
|
|
|
Runner implementation class name |
|
|
|
Modules containing trigger-dependent tasks |
|
|
|
Execute tasks synchronously in calling thread |
|
|
|
Logging level ( |
|
|
|
Print task arguments in log messages |
|
|
|
Maximum printed argument length |
|
|
|
Argument display mode: |
|
|
|
Invocation status cache TTL (seconds) |
|
|
|
Truncate IDs in log context for readability |
|
|
|
Cycle interval for atomic recovery services |
|
|
|
Safety margin for time-slot allocation |
|
|
|
Runner check interval for atomic services |
|
|
|
Cron expression for pending invocation recovery |
|
|
|
Maximum time an invocation can remain PENDING |
|
|
|
Cron expression for running invocation recovery |
|
|
|
Heartbeat timeout before runner is considered dead |
ConfigTask Fields¶
Per-task configuration (pynenc.conf.config_task.ConfigTask). Configurable globally or per-task.
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Batch size for |
|
|
|
Exception types that trigger a retry |
|
|
|
Maximum retry attempts (0 = no retries) |
|
|
|
Runtime concurrency control: |
|
|
|
Registration concurrency control: |
|
|
|
Arguments used for |
|
|
|
Raise error when non-key arguments differ in concurrency check |
|
|
|
Cache results by call arguments |
|
|
|
Arguments to exclude from cache key |
|
|
|
Always create a new workflow context |
|
|
|
Reroute blocked tasks instead of marking final |
Per-Task Configuration¶
Override settings for specific tasks using environment variables or config files:
Environment variables:
# Global task setting
PYNENC__CONFIGTASK__MAX_RETRIES="3"
# Task-specific (module#task separator)
PYNENC__CONFIGTASK__MYMODULE#MY_TASK__MAX_RETRIES="5"
Note
Use # (not __) to separate the module name from the task name in environment variables.
Configuration files:
task:
max_retries: 3
mymodule.my_task:
max_retries: 5
Task decorator:
@app.task(max_retries=5, running_concurrency="task")
def my_task(x: int) -> int:
return x * 2
ConfigRunner Fields¶
Base runner configuration (pynenc.conf.config_runner.ConfigRunner).
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Sleep time between result polling checks |
|
|
|
Sleep time between runner loop iterations |
|
|
|
Minimum parallel execution slots |
ThreadRunner Configuration¶
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Minimum thread pool size |
|
|
|
Maximum thread pool size ( |
MultiThreadRunner Configuration¶
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Threads per child process |
|
|
|
Threads per child process |
|
|
|
Minimum worker processes |
|
|
|
Maximum worker processes ( |
|
|
|
Seconds idle before a process is terminated |
|
|
|
Always maintain |
PersistentProcessRunner Configuration¶
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
CPU count |
Number of persistent worker processes |
Plugin Configuration¶
Backend plugins add their own configuration sections. For example:
Redis Plugin¶
[tool.pynenc.redis]
redis_host = "localhost"
redis_port = 6379
redis_db = 0
MongoDB Plugin¶
[tool.pynenc.mongodb]
connection_string = "mongodb://localhost:27017"
database_name = "pynenc"
Hierarchical Resolution¶
Pynenc supports hierarchical configuration classes with inheritance. The most specific (child) configuration takes precedence:
[tool.pynenc]
test_field = "default"
[tool.pynenc.child]
test_field = "child_override"
See Architecture for how configuration fits within the architecture.
See PynencBuilder Reference for programmatic configuration with PynencBuilder.