1919
2020 from aws_durable_execution_sdk_python .lambda_service import OperationSubType
2121 from aws_durable_execution_sdk_python .serdes import SerDes
22+ from aws_durable_execution_sdk_python .types import SummaryGenerator
2223
2324
2425Numeric = int | float # deliberately leaving off complex
@@ -39,6 +40,38 @@ class TerminationMode(Enum):
3940
4041@dataclass (frozen = True )
4142class CompletionConfig :
43+ """Configuration for determining when parallel/map operations complete.
44+
45+ This class defines the success/failure criteria for operations that process
46+ multiple items or branches concurrently.
47+
48+ Args:
49+ min_successful: Minimum number of successful completions required.
50+ If None, no minimum is enforced. Use this to implement "at least N
51+ must succeed" semantics.
52+
53+ tolerated_failure_count: Maximum number of failures allowed before
54+ the operation is considered failed. If None, no limit on failure count.
55+ Use this to implement "fail fast after N failures" semantics.
56+
57+ tolerated_failure_percentage: Maximum percentage of failures allowed
58+ (0.0 to 100.0). If None, no percentage limit is enforced.
59+ Use this to implement "fail if more than X% fail" semantics.
60+
61+ Note:
62+ The operation completes when any of the completion criteria are met:
63+ - Enough successes (min_successful reached)
64+ - Too many failures (tolerated limits exceeded)
65+ - All items/branches completed
66+
67+ Example:
68+ # Succeed if at least 3 succeed, fail if more than 2 fail
69+ config = CompletionConfig(
70+ min_successful=3,
71+ tolerated_failure_count=2
72+ )
73+ """
74+
4275 min_successful : int | None = None
4376 tolerated_failure_count : int | None = None
4477 tolerated_failure_percentage : int | float | None = None
@@ -77,11 +110,47 @@ def all_successful():
77110
78111@dataclass (frozen = True )
79112class ParallelConfig :
113+ """Configuration options for parallel execution operations.
114+
115+ This class configures how parallel operations are executed, including
116+ concurrency limits, completion criteria, and serialization behavior.
117+
118+ Args:
119+ max_concurrency: Maximum number of parallel branches to execute concurrently.
120+ If None, no limit is imposed and all branches run concurrently.
121+ Use this to control resource usage and prevent overwhelming the system.
122+
123+ completion_config: Defines when the parallel operation should complete.
124+ Controls success/failure criteria for the overall parallel operation.
125+ Default is CompletionConfig.all_successful() which requires all branches
126+ to succeed. Other options include first_successful() and all_completed().
127+
128+ serdes: Custom serialization/deserialization configuration for parallel results.
129+ If None, uses the default serializer. This allows custom handling of
130+ complex result types or optimization for large result sets.
131+
132+ summary_generator: Function to generate compact summaries for large results (>256KB).
133+ When the serialized result exceeds CHECKPOINT_SIZE_LIMIT, this generator
134+ creates a JSON summary instead of checkpointing the full result. The operation
135+ is marked with ReplayChildren=true to reconstruct the full result during replay.
136+
137+ Used internally by map/parallel operations to handle large BatchResult payloads.
138+ Signature: (result: T) -> str
139+
140+ Example:
141+ # Run at most 3 branches concurrently, succeed if any one succeeds
142+ config = ParallelConfig(
143+ max_concurrency=3,
144+ completion_config=CompletionConfig.first_successful()
145+ )
146+ """
147+
80148 max_concurrency : int | None = None
81149 completion_config : CompletionConfig = field (
82150 default_factory = CompletionConfig .all_successful
83151 )
84152 serdes : SerDes | None = None
153+ summary_generator : SummaryGenerator | None = None
85154
86155
87156class StepSemantics (Enum ):
@@ -106,12 +175,41 @@ class CheckpointMode(Enum):
106175
107176@dataclass (frozen = True )
108177class ChildConfig (Generic [T ]):
109- """Options when running inside a child context."""
178+ """Configuration options for child context operations.
179+
180+ This class configures how child contexts are executed and checkpointed,
181+ matching the TypeScript ChildConfig interface behavior.
182+
183+ Args:
184+ serdes: Custom serialization/deserialization configuration for the child context data.
185+ If None, uses the default serializer. This allows different serialization
186+ strategies for child operations vs parent operations.
187+
188+ sub_type: Operation subtype identifier used for tracking and debugging.
189+ Examples: OperationSubType.MAP_ITERATION, OperationSubType.PARALLEL_BRANCH.
190+ Used internally by the execution engine for operation classification.
191+
192+ summary_generator: Function to generate compact summaries for large results (>256KB).
193+ When the serialized result exceeds CHECKPOINT_SIZE_LIMIT, this generator
194+ creates a JSON summary instead of checkpointing the full result. The operation
195+ is marked with ReplayChildren=true to reconstruct the full result during replay.
196+
197+ Used internally by map/parallel operations to handle large BatchResult payloads.
198+ Signature: (result: T) -> str
199+ Note:
200+ checkpoint_mode field is commented out as it's not currently implemented.
201+ When implemented, it will control when checkpoints are created:
202+ - CHECKPOINT_AT_START_AND_FINISH: Checkpoint at both start and completion (default)
203+ - CHECKPOINT_AT_FINISH: Only checkpoint when operation completes
204+ - NO_CHECKPOINT: No automatic checkpointing
205+
206+ See TypeScript reference: aws-durable-execution-sdk-js/src/types/index.ts
207+ """
110208
111209 # checkpoint_mode: CheckpointMode = CheckpointMode.CHECKPOINT_AT_START_AND_FINISH
112210 serdes : SerDes | None = None
113211 sub_type : OperationSubType | None = None
114- summary_generator : Callable [[ T ], str ] | None = None
212+ summary_generator : SummaryGenerator | None = None
115213
116214
117215class ItemsPerBatchUnit (Enum ):
@@ -121,17 +219,86 @@ class ItemsPerBatchUnit(Enum):
121219
122220@dataclass (frozen = True )
123221class ItemBatcher (Generic [T ]):
222+ """Configuration for batching items in map operations.
223+
224+ This class defines how individual items should be grouped together into batches
225+ for more efficient processing in map operations.
226+
227+ Args:
228+ max_items_per_batch: Maximum number of items to include in a single batch.
229+ If 0 (default), no item count limit is applied. Use this to control
230+ batch size when processing many small items.
231+
232+ max_item_bytes_per_batch: Maximum total size in bytes for items in a batch.
233+ If 0 (default), no size limit is applied. Use this to control memory
234+ usage when processing large items or when items vary significantly in size.
235+
236+ batch_input: Additional data to include with each batch.
237+ This data is passed to the processing function along with the batched items.
238+ Useful for providing context or configuration that applies to all items
239+ in the batch.
240+
241+ Example:
242+ # Batch up to 100 items or 1MB, whichever comes first
243+ batcher = ItemBatcher(
244+ max_items_per_batch=100,
245+ max_item_bytes_per_batch=1024*1024,
246+ batch_input={"processing_mode": "fast"}
247+ )
248+ """
249+
124250 max_items_per_batch : int = 0
125251 max_item_bytes_per_batch : int | float = 0
126252 batch_input : T | None = None
127253
128254
129255@dataclass (frozen = True )
130256class MapConfig :
257+ """Configuration options for map operations over collections.
258+
259+ This class configures how map operations process collections of items,
260+ including concurrency, batching, completion criteria, and serialization.
261+
262+ Args:
263+ max_concurrency: Maximum number of items to process concurrently.
264+ If None, no limit is imposed and all items are processed concurrently.
265+ Use this to control resource usage when processing large collections.
266+
267+ item_batcher: Configuration for batching multiple items together for processing.
268+ Allows grouping items by count or size to optimize processing efficiency.
269+ Default is no batching (each item processed individually).
270+
271+ completion_config: Defines when the map operation should complete.
272+ Controls success/failure criteria for the overall map operation.
273+ Default allows any number of failures. Use CompletionConfig.all_successful()
274+ to require all items to succeed.
275+
276+ serdes: Custom serialization/deserialization configuration for map results.
277+ If None, uses the default serializer. This allows custom handling of
278+ complex item types or optimization for large result collections.
279+
280+ summary_generator: Function to generate compact summaries for large results (>256KB).
281+ When the serialized result exceeds CHECKPOINT_SIZE_LIMIT, this generator
282+ creates a JSON summary instead of checkpointing the full result. The operation
283+ is marked with ReplayChildren=true to reconstruct the full result during replay.
284+
285+ Used internally by map/parallel operations to handle large BatchResult payloads.
286+ Signature: (result: T) -> str
287+
288+ Example:
289+ # Process 5 items at a time, batch by count, require all to succeed
290+ config = MapConfig(
291+ max_concurrency=5,
292+ item_batcher=ItemBatcher(max_items_per_batch=10),
293+ completion_config=CompletionConfig.all_successful()
294+ )
295+ """
296+
131297 max_concurrency : int | None = None
132298 item_batcher : ItemBatcher = field (default_factory = ItemBatcher )
133299 completion_config : CompletionConfig = field (default_factory = CompletionConfig )
134300 serdes : SerDes | None = None
301+ summary_generator : SummaryGenerator | None = None
135302
136303
137304@dataclass
0 commit comments