Python SDK¶
Execution SDK¶
The execution SDK (aws-durable-execution-sdk-python) runs in your Lambda functions. It
provides DurableContext, operations, and decorators. Install it in your Lambda
deployment package.
Testing SDK¶
The testing SDK (aws-durable-execution-sdk-python-testing) lets you test durable
functions locally without AWS. It provides DurableFunctionTestRunner, pytest
integration, and result inspection. Install it in your development environment only.
Decorators¶
The SDK provides decorators to mark functions as durable:
@durable_executionmarks your Lambda handler as a durable function.@durable_stepwraps a function so it can be passed tocontext.step(), binding any extra arguments and preserving the function name.@durable_with_child_contextwraps a function that receives a childDurableContext, for use withcontext.run_in_child_context().@durable_parallel_branchwraps a function into a namedParallelBranchforcontext.parallel(). Call it with an optionalnameto produce the decorator.@durable_wait_for_callbackwraps a submitter function forcontext.wait_for_callback(), binding extra arguments alongside thecallback_idandWaitForCallbackContext.
The Python SDK uses synchronous methods and does not support await.
2.x Upgrade¶
When upgrading from 1.x to 2.x, review the Python SDK migration guide in the
SDK repository.
The main changes are:
- Catch the typed, per-operation errors
StepError,InvokeError,ChildContextError, andWaitForConditionError(or the baseDurableOperationError) instead of the removedCallableRuntimeError. - Replace
except CallableRuntimeErrorafterBatchResult.throw_if_error()withChildContextError,SerDesError, andBatchCompletionError. - Catch serialization failures as
SerDesError(a direct child ofDurableExecutionsError) instead ofExecutionError. - Expect the first-run serialize/deserialize round trip for
step, child contexts,map/parallel, andwait_for_condition, and ensurewait_for_conditioninitial_stateis serializable by the configured serdes. - Read the new
attemptfield onStepContextandWaitForConditionCheckContext, and passattemptwhen constructing those contexts directly in tests.