AWS Durable Execution SDK for Python
raw JSON → 1.4.0 verified Mon Apr 27 auth: no python
The AWS Durable Execution SDK provides decorators and runtime for building durable, stateful workflows on AWS Lambda. It manages checkpointing, retries, and parallel execution. Current version 1.4.0 (requires Python >=3.11). Released about monthly.
pip install aws-durable-execution-sdk-python Common errors
error ModuleNotFoundError: No module named 'aws_durable_execution_sdk' ↓
cause Wrong import package name – PyPI name uses hyphens, but Python import uses underscores.
fix
Use 'import aws_durable_execution' or 'from aws_durable_execution import ...'.
error ImportError: cannot import name 'BatchResult' from 'aws_durable_execution.batch' ↓
cause In v1.4.0, BatchResult export moved to package root. Submodule import is no longer valid.
fix
Use 'from aws_durable_execution import BatchResult'.
error botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the Invoke operation: ... ↓
cause Lambda execution role lacks permissions to invoke functions (for durable_wait_for_callback or Step Functions execution).
fix
Add 'lambda:InvokeFunction' permission to the IAM role.
Warnings
breaking In v1.4.0, BatchResult import moved from submodule to package root. Importing from 'aws_durable_execution.batch' will raise ImportError. ↓
fix Use 'from aws_durable_execution import BatchResult'.
breaking In v1.4.0, map and parallel now exit early on empty input list, returning empty results. Previously they may have caused errors. ↓
fix Check that empty input handling is acceptable; no code change needed if implicit empty result is fine.
gotcha The SDK requires an active AWS Lambda execution environment. Running outside Lambda (e.g., locally) may fail due to missing Lambda runtime APIs or IAM permissions. ↓
fix Run within AWS Lambda, or use a mock library (not provided by SDK).
deprecated Using direct submodule imports (e.g., aws_durable_execution.context) is deprecated since v1.3.0 and may be removed in future. ↓
fix Use top-level imports from aws_durable_execution.
Imports
- durable wrong
from aws_durable_execution_sdk import durablecorrectfrom aws_durable_execution import durable - BatchResult wrong
from aws_durable_execution.batch import BatchResultcorrectfrom aws_durable_execution import BatchResult - ExecutionContext wrong
from aws_durable_execution.context import ExecutionContextcorrectfrom aws_durable_execution import ExecutionContext
Quickstart
from aws_durable_execution import durable
import os
# Set AWS_LAMBDA_FUNCTION_NAME and AWS_LAMBDA_FUNCTION_VERSION environment variables
os.environ.setdefault('AWS_LAMBDA_FUNCTION_NAME', 'my-function')
os.environ.setdefault('AWS_LAMBDA_FUNCTION_VERSION', '$LATEST')
@durable()
def my_workflow(event, context):
print("Hello from durable execution")
return {"status": "success"}
# Example invocation
if __name__ == '__main__':
result = my_workflow({}, None)
print(result)