2020 * Optional fields (Optional[str], default values)
2121 * Generates JSON Schema draft-07 automatically
2222 * Registers schemas as {task_name}_input and {task_name}_output
23+ - ⭐ CONFIGURATION FLAGS:
24+ * overwrite_task_def: Control whether to overwrite existing task definitions
25+ * strict_schema: Control JSON schema validation strictness (additionalProperties)
26+ * Both flags support environment variable override
27+ * Global: conductor.worker.all.<property>
28+ * Worker-specific: conductor.worker.<task_name>.<property>
2329
2430Usage:
2531 export CONDUCTOR_SERVER_URL="http://localhost:8080/api"
8591 task_definition_name = 'calculate' ,
8692 thread_count = 100 , # High concurrency - async workers can handle it!
8793 poll_timeout = 10 ,
88- register_task_def = True
94+ register_task_def = True , # Auto-register task definition with JSON schema
95+ overwrite_task_def = True , # Always update definition on server (default: true)
96+ strict_schema = False # Allow additional properties in schema (default: false)
8997)
9098async def calculate_fibonacci (n : int ) -> int :
9199 """
@@ -101,6 +109,11 @@ async def calculate_fibonacci(n: int) -> int:
101109 - Concurrency: Up to 100 concurrent tasks
102110 - Memory: ~3-6 MB per process
103111
112+ Configuration:
113+ - register_task_def=True: Auto-registers task definition + JSON schema
114+ - overwrite_task_def=True: Always updates server (default behavior)
115+ - strict_schema=False: Allows extra fields in input (lenient, default)
116+
104117 Note: This is a CPU-bound task (fibonacci calculation), which isn't
105118 ideal for async workers. Use this pattern for I/O-bound operations
106119 (HTTP calls, database queries, file I/O).
@@ -161,17 +174,18 @@ class OrderRequest:
161174
162175
163176# Create TaskDef with advanced configuration for the complex order worker
177+ # This demonstrates using task_def parameter to specify retry, timeout, and rate limiting
164178complex_order_task_def = TaskDef (
165179 name = 'process_complex_order' , # Will be overridden by task_definition_name
166180 description = 'Process customer orders with complex validation and retry logic' ,
167181 retry_count = 3 , # Retry up to 3 times on failure
168182 retry_logic = 'EXPONENTIAL_BACKOFF' , # Use exponential backoff between retries
169183 retry_delay_seconds = 10 , # Start with 10 second delay
170- backoff_scale_factor = 3 , # Double delay each retry (10s, 20s, 40s )
184+ backoff_scale_factor = 3 , # Triple delay each retry (10s, 30s, 90s )
171185 timeout_seconds = 600 , # Task must complete within 10 minutes
172186 response_timeout_seconds = 120 , # Each execution attempt has 2 minutes
173187 timeout_policy = 'RETRY' , # Retry on timeout
174- concurrent_exec_limit = 30 , # Max 5 concurrent executions
188+ concurrent_exec_limit = 30 , # Max 30 concurrent executions
175189 rate_limit_per_frequency = 100 , # Max 100 executions
176190 rate_limit_frequency_in_seconds = 60 , # Per 60 seconds
177191 poll_timeout_seconds = 30 # Long poll timeout for efficiency
@@ -180,8 +194,13 @@ class OrderRequest:
180194@worker_task (
181195 task_definition_name = 'process_complex_order' ,
182196 thread_count = 10 ,
183- register_task_def = True , # Will auto-generate and register JSON schema!
184- task_def = complex_order_task_def # Advanced task configuration
197+ register_task_def = True , # Auto-register task definition with JSON schemas
198+ task_def = complex_order_task_def , # Advanced task configuration (retry, timeout, rate limits)
199+ overwrite_task_def = True , # Always update task definition on server (default: true)
200+ strict_schema = False # Lenient validation - allows extra fields (default: false)
201+ # Can be overridden via env:
202+ # export conductor.worker.process_complex_order.overwrite_task_def=false
203+ # export conductor.worker.process_complex_order.strict_schema=true
185204)
186205async def process_complex_order (
187206 order : OrderRequest ,
@@ -203,19 +222,30 @@ async def process_complex_order(
203222 - Schema registered as: process_complex_order_input (v1)
204223
205224 2. ADVANCED TASK CONFIGURATION via task_def parameter:
206- - Retry policy: 3 retries with EXPONENTIAL_BACKOFF (10s, 20s, 40s )
225+ - Retry policy: 3 retries with EXPONENTIAL_BACKOFF (10s, 30s, 90s )
207226 - Timeouts: 10 min total, 2 min per execution
208227 - Rate limiting: Max 100 executions per 60 seconds
209- - Concurrency: Max 5 concurrent executions
228+ - Concurrency: Max 30 concurrent executions
210229 - All configured via TaskDef object passed to @worker_task
211230
231+ 3. CONFIGURATION FLAGS:
232+ - overwrite_task_def=True: Always updates task definition on server
233+ * Use False to preserve manual server changes
234+ * Configurable: export conductor.worker.process_complex_order.overwrite_task_def=false
235+
236+ - strict_schema=False: Lenient JSON schema validation (allows extra fields)
237+ * Use True for strict validation (rejects extra fields)
238+ * Configurable: export conductor.worker.process_complex_order.strict_schema=true
239+
212240 Benefits:
213241 - Input validation in Conductor UI
214242 - Type-safe workflow design
215243 - Auto-completion in workflow editor
216244 - Runtime validation of task inputs
217245 - Production-ready retry and timeout policies
218246 - Rate limiting to protect downstream services
247+ - Flexible schema validation modes
248+ - Environment-based configuration control
219249 """
220250 # Simulate order processing
221251 ctx = get_task_context ()
0 commit comments