Conversation
cfa93bd to
cbacaaf
Compare
|
I accidentally broke the last PR. So here's a new clean PR to add the distributed map operation with the restructure you suggested in your comment here (along with fixes to other issues you pointed out). But I made the these modifications to your proposed restructure:
I also used Thoughts on these changes? I made this graph of the new operation structure to more easily see how the components relate:
Besides the restructure, I also made the following fixes based on your comments:
|
ee54c16 to
50f5eba
Compare
Add ctx.distributed_map with inline, S3, and reader sources, the config, processor, completion, and destination types, the result types, and function-authoring helpers for item and batch handlers. Serialization lives in lambda_service.py with one dataclass per API shape. Translation happens only in the executor, so config.py has no runtime import from lambda_service. Tests are split by layer. Items, Output, and the record body are opaque strings, matching the API model, so any serdes works rather than JSON only. Every terminal state resolves with the summary, and throw_if_error() opts into raising. Missing details or a missing completion reason raise ExecutionError. The processor factories are batch, item_failures, and item_results. Source and destination factories are InlineSource, S3Source, ReaderSource, and S3Destination. Retry is max_retry_attempts and max_retry_duration on the processor. Passing DistributedMapResultConfig selects the DistributedMapResult return type statically. Only the result types and their enums are exported from the package root.
50f5eba to
1ae73e8
Compare

Summary
Adds the distributed map operation (
ctx.distributed_map) to the Python SDK:A map run processes a bounded dataset in parallel. A customer starts a map run from a durable function, naming a source to read items from, a processor function to invoke per batch, and concurrency, retry, and failure settings. The service reads items from the source, groups them into batches, invokes the processor for each batch, retries failures, tracks progress, routes successful results and failed items to destinations, and reports completion.
Changes
dmap/models.pyThe result types a customer receives back from a map run.
DistributedMapSummary: whatctx.distributed_mapreturns, describes the run's overall outcome.DistributedMapResult: returned when aDistributedMapResultConfigis passed. Contains individual map run item outcomes.DistributedMapResultItemandDistributedMapItemError: represent a single item's result / error.dmap/__init__.pyEmpty package marker for the
dmappackage.config.pyThe input types a customer constructs to describe a map run, and the distributed map enums.
DistributedMapConfig: optional settings for distributed map.DistributedMapResultConfig: subclass that additionally collects item results inline, selecting the return type statically.InlineSource,S3Source,ReaderSource: describe where map run items come from.DistributedMapProcessor: describes the Lambda that processes items, how outcomes are reported back, and how failing items are retried viamax_retry_attemptsandmax_retry_duration.DistributedMapCompletionConfig: defines item failure thresholds for marking the overall map run failed.S3Destination,DistributedMapOnSuccessConfig,DistributedMapOnFailureConfig,DistributedMapDestinationConfig: for routing successful and failed item records to S3.lambda_service, soconfig.pyhas no runtime import from it.context.pyThe customer-facing entry point on the durable execution context.
ctx.distributed_map: the method a customer calls to run a distributed map. Overloaded so passing aDistributedMapResultConfigtypes the return asDistributedMapResultand anything else asDistributedMapSummary.max_concurrencyagainst the documented ceiling of 10000.dmap/handlers.pyAuthoring decorators for the processor Lambda, so a customer writes a plain function rather than the item or batch protocol.
distributed_map_item_handler,distributed_map_batch_handler,distributed_map_reader, and the durable variantsdurable_distributed_map_item_handleranddurable_distributed_map_batch_handler.durable_execution, so they work bare, with options, or called directly with a function.operation/dmap.pyThe executor that drives the operation against the durable execution runtime.
throw_if_error()opts into raising.lambda_service.pySerialization for carrying the operation and its results to and from the backend service.
Wiresuffix.Items,Output, and the record body are opaque strings, matching the API model, so any serdes works rather than JSON only.state.pyDurable execution state handling, so a run's outcome persists across suspend and resume.
exceptions.pyThe error type a customer catches.
DistributedMapError: raised when a run or an item fails.plugin.pyOperation type registration.
DISTRIBUTED_MAPtoOperationType.__init__.pyThe package's public API surface.
durable_executionanddurable_stepare exported.config.Tests
Tests are split by layer so each sits alongside its module.
tests/config_test.pytests/lambda_service_test.pytests/dmap/models_test.pytests/operation/dmap_test.pytests/context_test.pyctx.distributed_mapsurface.tests/dmap/handlers_test.pytests/e2e/dmap_int_test.pytests/e2e/dmap_helpers_int_test.pyFuture Tasks
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.