async-durable-execution-runner 2.0.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- async_durable_execution_runner-2.0.0a1/.gitignore +40 -0
- async_durable_execution_runner-2.0.0a1/LICENSE +175 -0
- async_durable_execution_runner-2.0.0a1/NOTICE +1 -0
- async_durable_execution_runner-2.0.0a1/PKG-INFO +238 -0
- async_durable_execution_runner-2.0.0a1/README.md +214 -0
- async_durable_execution_runner-2.0.0a1/VERSION.py +5 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/__about__.py +33 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/__init__.py +23 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/__init__.py +1 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/processor.py +101 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/processors/__init__.py +1 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/processors/base.py +199 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/processors/callback.py +89 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/processors/context.py +59 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/processors/execution.py +52 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/processors/step.py +124 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/processors/wait.py +95 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/transformer.py +104 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/__init__.py +1 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/checkpoint.py +242 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/operations/__init__.py +1 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/operations/callback.py +45 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/operations/context.py +73 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/operations/execution.py +47 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/operations/invoke.py +56 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/operations/step.py +106 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/operations/wait.py +54 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/checkpoint/validators/transitions.py +66 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/cli.py +498 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/client.py +50 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/exceptions.py +288 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/execution.py +444 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/executor.py +1234 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/invoker.py +340 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/model.py +3296 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/observer.py +144 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/py.typed +1 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/runner.py +1167 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/scheduler.py +246 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/stores/__init__.py +1 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/stores/base.py +147 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/stores/filesystem.py +79 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/stores/memory.py +38 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/stores/sqlite.py +273 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/token.py +49 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/web/__init__.py +1 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/web/errors.py +8 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/web/handlers.py +813 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/web/models.py +266 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/web/routes.py +692 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/web/serialization.py +235 -0
- async_durable_execution_runner-2.0.0a1/async_durable_execution_runner/web/server.py +243 -0
- async_durable_execution_runner-2.0.0a1/pyproject.toml +143 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
*~
|
|
2
|
+
*#
|
|
3
|
+
*.swp
|
|
4
|
+
*.iml
|
|
5
|
+
*.DS_Store
|
|
6
|
+
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*$py.class
|
|
10
|
+
*.egg-info/
|
|
11
|
+
|
|
12
|
+
*.coverage
|
|
13
|
+
/.coverage
|
|
14
|
+
/.coverage.*
|
|
15
|
+
/.cache
|
|
16
|
+
/.pytest_cache
|
|
17
|
+
/.mypy_cache
|
|
18
|
+
/.vscode
|
|
19
|
+
|
|
20
|
+
/doc/_apidoc/
|
|
21
|
+
/build
|
|
22
|
+
|
|
23
|
+
.venv
|
|
24
|
+
.venv/
|
|
25
|
+
|
|
26
|
+
.attach_*
|
|
27
|
+
|
|
28
|
+
dist/
|
|
29
|
+
|
|
30
|
+
.idea
|
|
31
|
+
|
|
32
|
+
.kiro/
|
|
33
|
+
|
|
34
|
+
**/build/
|
|
35
|
+
**/*.zip
|
|
36
|
+
packages/async-durable-execution-examples/template.yaml
|
|
37
|
+
**/template.generated.json
|
|
38
|
+
|
|
39
|
+
.env
|
|
40
|
+
*.egg-info
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: async-durable-execution-runner
|
|
3
|
+
Version: 2.0.0a1
|
|
4
|
+
Summary: Community-maintained durable execution local and cloud test runner for Python
|
|
5
|
+
Project-URL: Documentation, https://github.com/zhongkechen/async-durable-execution#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/zhongkechen/async-durable-execution/issues
|
|
7
|
+
Project-URL: Source, https://github.com/zhongkechen/async-durable-execution
|
|
8
|
+
Author: Zhongke Chen
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: async-durable-execution>=1.0.0
|
|
22
|
+
Requires-Dist: boto3>=1.42.1
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# Async Durable Execution Runner for Python
|
|
26
|
+
|
|
27
|
+
[](https://pypi.org/project/async-durable-execution-runner)
|
|
28
|
+
[](https://pypi.org/project/async-durable-execution-runner)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
[](https://scorecard.dev/viewer/?uri=github.com/zhongkechen/async-durable-execution)
|
|
32
|
+
|
|
33
|
+
-----
|
|
34
|
+
|
|
35
|
+
## Table of Contents
|
|
36
|
+
|
|
37
|
+
- [Installation](#installation)
|
|
38
|
+
- [Quick Start](#quick-start)
|
|
39
|
+
- [Architecture](#architecture)
|
|
40
|
+
- [Documentation](#documentation)
|
|
41
|
+
- [Developer Guide](#developers)
|
|
42
|
+
- [License](#license)
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
pip install async-durable-execution-runner
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Overview
|
|
51
|
+
|
|
52
|
+
Use Async Durable Execution Runner for Python to test your Python durable functions locally and in cloud environments.
|
|
53
|
+
|
|
54
|
+
This package is distributed from a community-maintained fork of the original Apache-2.0 licensed AWS project and continues under Apache License 2.0 with upstream notices preserved.
|
|
55
|
+
|
|
56
|
+
The test framework contains a local runner, so you can run and test your durable function locally
|
|
57
|
+
before you deploy it.
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
### A durable function under test
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import asyncio
|
|
65
|
+
from typing import Any
|
|
66
|
+
|
|
67
|
+
from async_durable_execution import (
|
|
68
|
+
DurableContext,
|
|
69
|
+
durable_execution,
|
|
70
|
+
durable_step,
|
|
71
|
+
durable_with_child_context,
|
|
72
|
+
)
|
|
73
|
+
from async_durable_execution.config import Duration
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@durable_step
|
|
77
|
+
async def one(a: int, b: int) -> str:
|
|
78
|
+
await asyncio.sleep(0)
|
|
79
|
+
return f"{a} {b}"
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@durable_step
|
|
83
|
+
async def two_1(a: int, b: int) -> str:
|
|
84
|
+
await asyncio.sleep(0)
|
|
85
|
+
return f"{a} {b}"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@durable_step
|
|
89
|
+
async def two_2(a: int, b: int) -> str:
|
|
90
|
+
await asyncio.sleep(0)
|
|
91
|
+
return f"{b} {a}"
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@durable_with_child_context
|
|
95
|
+
async def two(ctx: DurableContext, a: int, b: int) -> str:
|
|
96
|
+
two_1_result: str = ctx.step(two_1(a, b))
|
|
97
|
+
two_2_result: str = ctx.step(two_2(a, b))
|
|
98
|
+
return f"{two_1_result} {two_2_result}"
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@durable_step
|
|
102
|
+
async def three(a: int, b: int) -> str:
|
|
103
|
+
await asyncio.sleep(0)
|
|
104
|
+
return f"{a} {b}"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@durable_execution
|
|
108
|
+
async def function_under_test(event: Any, context: DurableContext) -> list[str]:
|
|
109
|
+
results: list[str] = []
|
|
110
|
+
|
|
111
|
+
result_one: str = context.step(one(1, 2))
|
|
112
|
+
results.append(result_one)
|
|
113
|
+
|
|
114
|
+
context.wait(duration=Duration.from_seconds(1))
|
|
115
|
+
|
|
116
|
+
result_two: str = context.run_in_child_context(two(3, 4))
|
|
117
|
+
results.append(result_two)
|
|
118
|
+
|
|
119
|
+
result_three: str = context.step(three(5, 6))
|
|
120
|
+
results.append(result_three)
|
|
121
|
+
|
|
122
|
+
return results
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Your test code
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from async_durable_execution.execution import InvocationStatus
|
|
129
|
+
from async_durable_execution_runner.runner import (
|
|
130
|
+
ContextOperation,
|
|
131
|
+
DurableFunctionTestResult,
|
|
132
|
+
DurableFunctionTestRunner,
|
|
133
|
+
StepOperation,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def test_my_durable_functions():
|
|
138
|
+
with DurableFunctionTestRunner(handler=function_under_test) as runner:
|
|
139
|
+
result: DurableFunctionTestResult = runner.run(input="input str", timeout=10)
|
|
140
|
+
|
|
141
|
+
assert result.status is InvocationStatus.SUCCEEDED
|
|
142
|
+
assert result.result == '["1 2", "3 4 4 3", "5 6"]'
|
|
143
|
+
|
|
144
|
+
one_result: StepOperation = result.get_step("one")
|
|
145
|
+
assert one_result.result == '"1 2"'
|
|
146
|
+
|
|
147
|
+
two_result: ContextOperation = result.get_context("two")
|
|
148
|
+
assert two_result.result == '"3 4 4 3"'
|
|
149
|
+
|
|
150
|
+
three_result: StepOperation = result.get_step("three")
|
|
151
|
+
assert three_result.result == '"5 6"'
|
|
152
|
+
```
|
|
153
|
+
## Architecture
|
|
154
|
+

|
|
155
|
+
|
|
156
|
+
## Event Flow
|
|
157
|
+

|
|
158
|
+
|
|
159
|
+
1. **DurableTestRunner** starts execution via **Executor**
|
|
160
|
+
2. **Executor** creates **Execution** and schedules initial invocation
|
|
161
|
+
3. During execution, checkpoints are processed by **CheckpointProcessor**
|
|
162
|
+
4. **Individual Processors** transform operation updates and may trigger events
|
|
163
|
+
5. **ExecutionNotifier** broadcasts events to **Executor** (observer)
|
|
164
|
+
6. **Executor** updates **Execution** state based on events
|
|
165
|
+
7. **Execution** completion triggers final event notifications
|
|
166
|
+
8. **DurableTestRunner** run() blocks until it receives completion event, and then returns `DurableFunctionTestResult`.
|
|
167
|
+
|
|
168
|
+
## Major Components
|
|
169
|
+
|
|
170
|
+
### Core Execution Flow
|
|
171
|
+
- **DurableTestRunner** - Main entry point that orchestrates test execution
|
|
172
|
+
- **Executor** - Manages execution lifecycle. Mutates Execution.
|
|
173
|
+
- **Execution** - Represents the state and operations of a single durable execution
|
|
174
|
+
|
|
175
|
+
### Service Client Integration
|
|
176
|
+
- **InMemoryServiceClient** - Replaces AWS Lambda service client for local testing. Injected into SDK via `DurableExecutionInvocationInputWithClient`
|
|
177
|
+
|
|
178
|
+
### Checkpoint Processing Pipeline
|
|
179
|
+
- **CheckpointProcessor** - Orchestrates operation transformations and validation
|
|
180
|
+
- **Individual Validators** - Validate operation updates and state transitions
|
|
181
|
+
- **Individual Processors** - Transform operation updates into operations (step, wait, callback, context, execution)
|
|
182
|
+
|
|
183
|
+
### Execution status changes (Observer Pattern)
|
|
184
|
+
- **ExecutionNotifier** - Notifies observers of execution events
|
|
185
|
+
- **ExecutionObserver** - Interface for receiving execution lifecycle events
|
|
186
|
+
- **Executor** implements `ExecutionObserver` to handle completion events
|
|
187
|
+
|
|
188
|
+
## Component Relationships
|
|
189
|
+
|
|
190
|
+
### 1. DurableTestRunner → Executor → Execution
|
|
191
|
+
- **DurableTestRunner** serves as the main API entry point and sets up all components
|
|
192
|
+
- **Executor** manages the execution lifecycle, handling invocations and state transitions
|
|
193
|
+
- **Execution** maintains the state of operations and completion status
|
|
194
|
+
|
|
195
|
+
### 2. Service Client Injection
|
|
196
|
+
- **DurableTestRunner** creates **InMemoryServiceClient** with **CheckpointProcessor**
|
|
197
|
+
- **InProcessInvoker** injects the service client into SDK via `DurableExecutionInvocationInputWithClient`
|
|
198
|
+
- When durable functions call checkpoint operations, they're intercepted by **InMemoryServiceClient**
|
|
199
|
+
- **InMemoryServiceClient** delegates to **CheckpointProcessor** for local processing
|
|
200
|
+
|
|
201
|
+
### 3. CheckpointProcessor → Individual Validators → Individual Processors
|
|
202
|
+
- **CheckpointProcessor** orchestrates the checkpoint processing pipeline
|
|
203
|
+
- **Individual Validators** (CheckpointValidator, TransitionsValidator, and operation-specific validators) ensure operation updates are valid
|
|
204
|
+
- **Individual Processors** (StepProcessor, WaitProcessor, etc.) transform `OperationUpdate` into `Operation`
|
|
205
|
+
|
|
206
|
+
### 4. Observer Pattern Flow
|
|
207
|
+
The observer pattern enables loose coupling between checkpoint processing and execution management:
|
|
208
|
+
|
|
209
|
+
1. **CheckpointProcessor** processes operation updates
|
|
210
|
+
2. **Individual Processors** detect state changes (completion, failures, timer scheduling)
|
|
211
|
+
3. **ExecutionNotifier** broadcasts events to registered observers
|
|
212
|
+
4. **Executor** (as ExecutionObserver) receives notifications and updates **Execution** state
|
|
213
|
+
5. **Execution** complete_* methods finalize the execution state
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
## Documentation
|
|
217
|
+
|
|
218
|
+
### Error Handling
|
|
219
|
+
|
|
220
|
+
The testing framework implements AWS-compliant error responses that match the exact format expected by boto3 and AWS services. For detailed information about error response formats, exception types, and troubleshooting, see:
|
|
221
|
+
|
|
222
|
+
- [Error Response Documentation](docs/error-responses.md)
|
|
223
|
+
|
|
224
|
+
Key features:
|
|
225
|
+
- **AWS-compliant JSON format**: Matches boto3 expectations exactly
|
|
226
|
+
- **Smithy model compliance**: Field names follow AWS Smithy definitions
|
|
227
|
+
- **HTTP status code mapping**: Standard AWS service status codes
|
|
228
|
+
- **Boto3 compatibility**: Seamless integration with boto3 error handling
|
|
229
|
+
|
|
230
|
+
## Developers
|
|
231
|
+
Please see [CONTRIBUTING.md](../../CONTRIBUTING.md). It contains the testing guide, sample commands and instructions
|
|
232
|
+
for how to contribute to this package.
|
|
233
|
+
|
|
234
|
+
tldr; use `hatch` and it will manage virtual envs and dependencies for you, so you don't have to do it manually.
|
|
235
|
+
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
This project is licensed under the [Apache-2.0 License](../../LICENSE).
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Async Durable Execution Runner for Python
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/async-durable-execution-runner)
|
|
4
|
+
[](https://pypi.org/project/async-durable-execution-runner)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
[](https://scorecard.dev/viewer/?uri=github.com/zhongkechen/async-durable-execution)
|
|
8
|
+
|
|
9
|
+
-----
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
- [Installation](#installation)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
15
|
+
- [Architecture](#architecture)
|
|
16
|
+
- [Documentation](#documentation)
|
|
17
|
+
- [Developer Guide](#developers)
|
|
18
|
+
- [License](#license)
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```console
|
|
23
|
+
pip install async-durable-execution-runner
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Overview
|
|
27
|
+
|
|
28
|
+
Use Async Durable Execution Runner for Python to test your Python durable functions locally and in cloud environments.
|
|
29
|
+
|
|
30
|
+
This package is distributed from a community-maintained fork of the original Apache-2.0 licensed AWS project and continues under Apache License 2.0 with upstream notices preserved.
|
|
31
|
+
|
|
32
|
+
The test framework contains a local runner, so you can run and test your durable function locally
|
|
33
|
+
before you deploy it.
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
### A durable function under test
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import asyncio
|
|
41
|
+
from typing import Any
|
|
42
|
+
|
|
43
|
+
from async_durable_execution import (
|
|
44
|
+
DurableContext,
|
|
45
|
+
durable_execution,
|
|
46
|
+
durable_step,
|
|
47
|
+
durable_with_child_context,
|
|
48
|
+
)
|
|
49
|
+
from async_durable_execution.config import Duration
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@durable_step
|
|
53
|
+
async def one(a: int, b: int) -> str:
|
|
54
|
+
await asyncio.sleep(0)
|
|
55
|
+
return f"{a} {b}"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@durable_step
|
|
59
|
+
async def two_1(a: int, b: int) -> str:
|
|
60
|
+
await asyncio.sleep(0)
|
|
61
|
+
return f"{a} {b}"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@durable_step
|
|
65
|
+
async def two_2(a: int, b: int) -> str:
|
|
66
|
+
await asyncio.sleep(0)
|
|
67
|
+
return f"{b} {a}"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@durable_with_child_context
|
|
71
|
+
async def two(ctx: DurableContext, a: int, b: int) -> str:
|
|
72
|
+
two_1_result: str = ctx.step(two_1(a, b))
|
|
73
|
+
two_2_result: str = ctx.step(two_2(a, b))
|
|
74
|
+
return f"{two_1_result} {two_2_result}"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@durable_step
|
|
78
|
+
async def three(a: int, b: int) -> str:
|
|
79
|
+
await asyncio.sleep(0)
|
|
80
|
+
return f"{a} {b}"
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@durable_execution
|
|
84
|
+
async def function_under_test(event: Any, context: DurableContext) -> list[str]:
|
|
85
|
+
results: list[str] = []
|
|
86
|
+
|
|
87
|
+
result_one: str = context.step(one(1, 2))
|
|
88
|
+
results.append(result_one)
|
|
89
|
+
|
|
90
|
+
context.wait(duration=Duration.from_seconds(1))
|
|
91
|
+
|
|
92
|
+
result_two: str = context.run_in_child_context(two(3, 4))
|
|
93
|
+
results.append(result_two)
|
|
94
|
+
|
|
95
|
+
result_three: str = context.step(three(5, 6))
|
|
96
|
+
results.append(result_three)
|
|
97
|
+
|
|
98
|
+
return results
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Your test code
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from async_durable_execution.execution import InvocationStatus
|
|
105
|
+
from async_durable_execution_runner.runner import (
|
|
106
|
+
ContextOperation,
|
|
107
|
+
DurableFunctionTestResult,
|
|
108
|
+
DurableFunctionTestRunner,
|
|
109
|
+
StepOperation,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_my_durable_functions():
|
|
114
|
+
with DurableFunctionTestRunner(handler=function_under_test) as runner:
|
|
115
|
+
result: DurableFunctionTestResult = runner.run(input="input str", timeout=10)
|
|
116
|
+
|
|
117
|
+
assert result.status is InvocationStatus.SUCCEEDED
|
|
118
|
+
assert result.result == '["1 2", "3 4 4 3", "5 6"]'
|
|
119
|
+
|
|
120
|
+
one_result: StepOperation = result.get_step("one")
|
|
121
|
+
assert one_result.result == '"1 2"'
|
|
122
|
+
|
|
123
|
+
two_result: ContextOperation = result.get_context("two")
|
|
124
|
+
assert two_result.result == '"3 4 4 3"'
|
|
125
|
+
|
|
126
|
+
three_result: StepOperation = result.get_step("three")
|
|
127
|
+
assert three_result.result == '"5 6"'
|
|
128
|
+
```
|
|
129
|
+
## Architecture
|
|
130
|
+

|
|
131
|
+
|
|
132
|
+
## Event Flow
|
|
133
|
+

|
|
134
|
+
|
|
135
|
+
1. **DurableTestRunner** starts execution via **Executor**
|
|
136
|
+
2. **Executor** creates **Execution** and schedules initial invocation
|
|
137
|
+
3. During execution, checkpoints are processed by **CheckpointProcessor**
|
|
138
|
+
4. **Individual Processors** transform operation updates and may trigger events
|
|
139
|
+
5. **ExecutionNotifier** broadcasts events to **Executor** (observer)
|
|
140
|
+
6. **Executor** updates **Execution** state based on events
|
|
141
|
+
7. **Execution** completion triggers final event notifications
|
|
142
|
+
8. **DurableTestRunner** run() blocks until it receives completion event, and then returns `DurableFunctionTestResult`.
|
|
143
|
+
|
|
144
|
+
## Major Components
|
|
145
|
+
|
|
146
|
+
### Core Execution Flow
|
|
147
|
+
- **DurableTestRunner** - Main entry point that orchestrates test execution
|
|
148
|
+
- **Executor** - Manages execution lifecycle. Mutates Execution.
|
|
149
|
+
- **Execution** - Represents the state and operations of a single durable execution
|
|
150
|
+
|
|
151
|
+
### Service Client Integration
|
|
152
|
+
- **InMemoryServiceClient** - Replaces AWS Lambda service client for local testing. Injected into SDK via `DurableExecutionInvocationInputWithClient`
|
|
153
|
+
|
|
154
|
+
### Checkpoint Processing Pipeline
|
|
155
|
+
- **CheckpointProcessor** - Orchestrates operation transformations and validation
|
|
156
|
+
- **Individual Validators** - Validate operation updates and state transitions
|
|
157
|
+
- **Individual Processors** - Transform operation updates into operations (step, wait, callback, context, execution)
|
|
158
|
+
|
|
159
|
+
### Execution status changes (Observer Pattern)
|
|
160
|
+
- **ExecutionNotifier** - Notifies observers of execution events
|
|
161
|
+
- **ExecutionObserver** - Interface for receiving execution lifecycle events
|
|
162
|
+
- **Executor** implements `ExecutionObserver` to handle completion events
|
|
163
|
+
|
|
164
|
+
## Component Relationships
|
|
165
|
+
|
|
166
|
+
### 1. DurableTestRunner → Executor → Execution
|
|
167
|
+
- **DurableTestRunner** serves as the main API entry point and sets up all components
|
|
168
|
+
- **Executor** manages the execution lifecycle, handling invocations and state transitions
|
|
169
|
+
- **Execution** maintains the state of operations and completion status
|
|
170
|
+
|
|
171
|
+
### 2. Service Client Injection
|
|
172
|
+
- **DurableTestRunner** creates **InMemoryServiceClient** with **CheckpointProcessor**
|
|
173
|
+
- **InProcessInvoker** injects the service client into SDK via `DurableExecutionInvocationInputWithClient`
|
|
174
|
+
- When durable functions call checkpoint operations, they're intercepted by **InMemoryServiceClient**
|
|
175
|
+
- **InMemoryServiceClient** delegates to **CheckpointProcessor** for local processing
|
|
176
|
+
|
|
177
|
+
### 3. CheckpointProcessor → Individual Validators → Individual Processors
|
|
178
|
+
- **CheckpointProcessor** orchestrates the checkpoint processing pipeline
|
|
179
|
+
- **Individual Validators** (CheckpointValidator, TransitionsValidator, and operation-specific validators) ensure operation updates are valid
|
|
180
|
+
- **Individual Processors** (StepProcessor, WaitProcessor, etc.) transform `OperationUpdate` into `Operation`
|
|
181
|
+
|
|
182
|
+
### 4. Observer Pattern Flow
|
|
183
|
+
The observer pattern enables loose coupling between checkpoint processing and execution management:
|
|
184
|
+
|
|
185
|
+
1. **CheckpointProcessor** processes operation updates
|
|
186
|
+
2. **Individual Processors** detect state changes (completion, failures, timer scheduling)
|
|
187
|
+
3. **ExecutionNotifier** broadcasts events to registered observers
|
|
188
|
+
4. **Executor** (as ExecutionObserver) receives notifications and updates **Execution** state
|
|
189
|
+
5. **Execution** complete_* methods finalize the execution state
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
## Documentation
|
|
193
|
+
|
|
194
|
+
### Error Handling
|
|
195
|
+
|
|
196
|
+
The testing framework implements AWS-compliant error responses that match the exact format expected by boto3 and AWS services. For detailed information about error response formats, exception types, and troubleshooting, see:
|
|
197
|
+
|
|
198
|
+
- [Error Response Documentation](docs/error-responses.md)
|
|
199
|
+
|
|
200
|
+
Key features:
|
|
201
|
+
- **AWS-compliant JSON format**: Matches boto3 expectations exactly
|
|
202
|
+
- **Smithy model compliance**: Field names follow AWS Smithy definitions
|
|
203
|
+
- **HTTP status code mapping**: Standard AWS service status codes
|
|
204
|
+
- **Boto3 compatibility**: Seamless integration with boto3 error handling
|
|
205
|
+
|
|
206
|
+
## Developers
|
|
207
|
+
Please see [CONTRIBUTING.md](../../CONTRIBUTING.md). It contains the testing guide, sample commands and instructions
|
|
208
|
+
for how to contribute to this package.
|
|
209
|
+
|
|
210
|
+
tldr; use `hatch` and it will manage virtual envs and dependencies for you, so you don't have to do it manually.
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
This project is licensed under the [Apache-2.0 License](../../LICENSE).
|