aws-durable-execution-sdk-python-testing 1.0.0__py3-none-any.whl
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.
- aws_durable_execution_sdk_python_testing/__about__.py +4 -0
- aws_durable_execution_sdk_python_testing/__init__.py +20 -0
- aws_durable_execution_sdk_python_testing/checkpoint/__init__.py +1 -0
- aws_durable_execution_sdk_python_testing/checkpoint/processor.py +101 -0
- aws_durable_execution_sdk_python_testing/checkpoint/processors/__init__.py +1 -0
- aws_durable_execution_sdk_python_testing/checkpoint/processors/base.py +199 -0
- aws_durable_execution_sdk_python_testing/checkpoint/processors/callback.py +89 -0
- aws_durable_execution_sdk_python_testing/checkpoint/processors/context.py +59 -0
- aws_durable_execution_sdk_python_testing/checkpoint/processors/execution.py +52 -0
- aws_durable_execution_sdk_python_testing/checkpoint/processors/step.py +124 -0
- aws_durable_execution_sdk_python_testing/checkpoint/processors/wait.py +95 -0
- aws_durable_execution_sdk_python_testing/checkpoint/transformer.py +104 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/__init__.py +1 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/checkpoint.py +242 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/__init__.py +1 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/callback.py +45 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/context.py +73 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/execution.py +47 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/invoke.py +56 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/step.py +106 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/wait.py +54 -0
- aws_durable_execution_sdk_python_testing/checkpoint/validators/transitions.py +66 -0
- aws_durable_execution_sdk_python_testing/cli.py +501 -0
- aws_durable_execution_sdk_python_testing/client.py +50 -0
- aws_durable_execution_sdk_python_testing/exceptions.py +288 -0
- aws_durable_execution_sdk_python_testing/execution.py +440 -0
- aws_durable_execution_sdk_python_testing/executor.py +1214 -0
- aws_durable_execution_sdk_python_testing/invoker.py +327 -0
- aws_durable_execution_sdk_python_testing/model.py +3267 -0
- aws_durable_execution_sdk_python_testing/observer.py +144 -0
- aws_durable_execution_sdk_python_testing/py.typed +1 -0
- aws_durable_execution_sdk_python_testing/runner.py +1185 -0
- aws_durable_execution_sdk_python_testing/scheduler.py +246 -0
- aws_durable_execution_sdk_python_testing/stores/__init__.py +1 -0
- aws_durable_execution_sdk_python_testing/stores/base.py +147 -0
- aws_durable_execution_sdk_python_testing/stores/filesystem.py +104 -0
- aws_durable_execution_sdk_python_testing/stores/memory.py +38 -0
- aws_durable_execution_sdk_python_testing/stores/sqlite.py +283 -0
- aws_durable_execution_sdk_python_testing/token.py +49 -0
- aws_durable_execution_sdk_python_testing/web/__init__.py +1 -0
- aws_durable_execution_sdk_python_testing/web/errors.py +8 -0
- aws_durable_execution_sdk_python_testing/web/handlers.py +807 -0
- aws_durable_execution_sdk_python_testing/web/models.py +266 -0
- aws_durable_execution_sdk_python_testing/web/routes.py +684 -0
- aws_durable_execution_sdk_python_testing/web/serialization.py +245 -0
- aws_durable_execution_sdk_python_testing/web/server.py +243 -0
- aws_durable_execution_sdk_python_testing-1.0.0.dist-info/METADATA +221 -0
- aws_durable_execution_sdk_python_testing-1.0.0.dist-info/RECORD +52 -0
- aws_durable_execution_sdk_python_testing-1.0.0.dist-info/WHEEL +4 -0
- aws_durable_execution_sdk_python_testing-1.0.0.dist-info/entry_points.txt +2 -0
- aws_durable_execution_sdk_python_testing-1.0.0.dist-info/licenses/LICENSE +175 -0
- aws_durable_execution_sdk_python_testing-1.0.0.dist-info/licenses/NOTICE +1 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Step operation validator."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from aws_durable_execution_sdk_python.lambda_service import (
|
|
6
|
+
Operation,
|
|
7
|
+
OperationAction,
|
|
8
|
+
OperationStatus,
|
|
9
|
+
OperationUpdate,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from aws_durable_execution_sdk_python_testing.exceptions import (
|
|
13
|
+
InvalidParameterValueException,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
VALID_ACTIONS_FOR_STEP = frozenset(
|
|
18
|
+
[
|
|
19
|
+
OperationAction.START,
|
|
20
|
+
OperationAction.FAIL,
|
|
21
|
+
OperationAction.RETRY,
|
|
22
|
+
OperationAction.SUCCEED,
|
|
23
|
+
]
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class StepOperationValidator:
|
|
28
|
+
"""Validates STEP operation transitions."""
|
|
29
|
+
|
|
30
|
+
_ALLOWED_STATUS_TO_CLOSE = frozenset(
|
|
31
|
+
[
|
|
32
|
+
OperationStatus.STARTED,
|
|
33
|
+
OperationStatus.READY,
|
|
34
|
+
]
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
_ALLOWED_STATUS_TO_START = frozenset(
|
|
38
|
+
[
|
|
39
|
+
OperationStatus.READY,
|
|
40
|
+
]
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
_ALLOWED_STATUS_TO_REATTEMPT = frozenset(
|
|
44
|
+
[
|
|
45
|
+
OperationStatus.STARTED,
|
|
46
|
+
OperationStatus.READY,
|
|
47
|
+
]
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def validate(current_state: Operation | None, update: OperationUpdate) -> None:
|
|
52
|
+
"""Validate STEP operation update."""
|
|
53
|
+
if current_state is None:
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
match update.action:
|
|
57
|
+
case OperationAction.START:
|
|
58
|
+
if (
|
|
59
|
+
current_state.status
|
|
60
|
+
not in StepOperationValidator._ALLOWED_STATUS_TO_START
|
|
61
|
+
):
|
|
62
|
+
msg_step_start: str = "Invalid current STEP state to start."
|
|
63
|
+
|
|
64
|
+
raise InvalidParameterValueException(msg_step_start)
|
|
65
|
+
case OperationAction.FAIL | OperationAction.SUCCEED:
|
|
66
|
+
if (
|
|
67
|
+
current_state.status
|
|
68
|
+
not in StepOperationValidator._ALLOWED_STATUS_TO_CLOSE
|
|
69
|
+
):
|
|
70
|
+
msg_step_close: str = "Invalid current STEP state to close."
|
|
71
|
+
|
|
72
|
+
raise InvalidParameterValueException(msg_step_close)
|
|
73
|
+
if update.action == OperationAction.FAIL and update.payload is not None:
|
|
74
|
+
msg_fail_payload: str = "Cannot provide a Payload for FAIL action."
|
|
75
|
+
|
|
76
|
+
raise InvalidParameterValueException(msg_fail_payload)
|
|
77
|
+
if (
|
|
78
|
+
update.action == OperationAction.SUCCEED
|
|
79
|
+
and update.error is not None
|
|
80
|
+
):
|
|
81
|
+
msg_succeed_error: str = (
|
|
82
|
+
"Cannot provide an Error for SUCCEED action."
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
raise InvalidParameterValueException(msg_succeed_error)
|
|
86
|
+
case OperationAction.RETRY:
|
|
87
|
+
if (
|
|
88
|
+
current_state.status
|
|
89
|
+
not in StepOperationValidator._ALLOWED_STATUS_TO_REATTEMPT
|
|
90
|
+
):
|
|
91
|
+
msg_step_retry: str = "Invalid current STEP state to re-attempt."
|
|
92
|
+
|
|
93
|
+
raise InvalidParameterValueException(msg_step_retry)
|
|
94
|
+
if update.step_options is None:
|
|
95
|
+
msg_step_options: str = "Invalid StepOptions for the given action."
|
|
96
|
+
|
|
97
|
+
raise InvalidParameterValueException(msg_step_options)
|
|
98
|
+
if update.error is not None and update.payload is not None:
|
|
99
|
+
msg_retry_both: str = (
|
|
100
|
+
"Cannot provide both error and payload to RETRY a STEP."
|
|
101
|
+
)
|
|
102
|
+
raise InvalidParameterValueException(msg_retry_both)
|
|
103
|
+
case _:
|
|
104
|
+
msg_step_invalid: str = "Invalid STEP action."
|
|
105
|
+
|
|
106
|
+
raise InvalidParameterValueException(msg_step_invalid)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Wait operation validator."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from aws_durable_execution_sdk_python.lambda_service import (
|
|
6
|
+
Operation,
|
|
7
|
+
OperationAction,
|
|
8
|
+
OperationStatus,
|
|
9
|
+
OperationUpdate,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from aws_durable_execution_sdk_python_testing.exceptions import (
|
|
13
|
+
InvalidParameterValueException,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
VALID_ACTIONS_FOR_WAIT = frozenset(
|
|
18
|
+
[
|
|
19
|
+
OperationAction.START,
|
|
20
|
+
OperationAction.CANCEL,
|
|
21
|
+
]
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class WaitOperationValidator:
|
|
26
|
+
"""Validates WAIT operation transitions."""
|
|
27
|
+
|
|
28
|
+
_ALLOWED_STATUS_TO_CANCEL = frozenset(
|
|
29
|
+
[
|
|
30
|
+
OperationStatus.STARTED,
|
|
31
|
+
]
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def validate(current_state: Operation | None, update: OperationUpdate) -> None:
|
|
36
|
+
"""Validate WAIT operation update."""
|
|
37
|
+
match update.action:
|
|
38
|
+
case OperationAction.START:
|
|
39
|
+
if current_state is not None:
|
|
40
|
+
msg_wait_exists: str = "Cannot start a WAIT that already exist."
|
|
41
|
+
|
|
42
|
+
raise InvalidParameterValueException(msg_wait_exists)
|
|
43
|
+
case OperationAction.CANCEL:
|
|
44
|
+
if (
|
|
45
|
+
current_state is None
|
|
46
|
+
or current_state.status
|
|
47
|
+
not in WaitOperationValidator._ALLOWED_STATUS_TO_CANCEL
|
|
48
|
+
):
|
|
49
|
+
msg_wait_cancel: str = "Cannot cancel a WAIT that does not exist or has already completed."
|
|
50
|
+
raise InvalidParameterValueException(msg_wait_cancel)
|
|
51
|
+
case _:
|
|
52
|
+
msg_wait_invalid: str = "Invalid WAIT action."
|
|
53
|
+
|
|
54
|
+
raise InvalidParameterValueException(msg_wait_invalid)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Validator for valid actions by operation type."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import ClassVar
|
|
6
|
+
|
|
7
|
+
from aws_durable_execution_sdk_python.lambda_service import (
|
|
8
|
+
OperationAction,
|
|
9
|
+
OperationType,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from aws_durable_execution_sdk_python_testing.checkpoint.validators.operations.callback import (
|
|
13
|
+
VALID_ACTIONS_FOR_CALLBACK,
|
|
14
|
+
)
|
|
15
|
+
from aws_durable_execution_sdk_python_testing.checkpoint.validators.operations.context import (
|
|
16
|
+
VALID_ACTIONS_FOR_CONTEXT,
|
|
17
|
+
)
|
|
18
|
+
from aws_durable_execution_sdk_python_testing.checkpoint.validators.operations.execution import (
|
|
19
|
+
VALID_ACTIONS_FOR_EXECUTION,
|
|
20
|
+
)
|
|
21
|
+
from aws_durable_execution_sdk_python_testing.checkpoint.validators.operations.invoke import (
|
|
22
|
+
VALID_ACTIONS_FOR_INVOKE,
|
|
23
|
+
)
|
|
24
|
+
from aws_durable_execution_sdk_python_testing.checkpoint.validators.operations.step import (
|
|
25
|
+
VALID_ACTIONS_FOR_STEP,
|
|
26
|
+
)
|
|
27
|
+
from aws_durable_execution_sdk_python_testing.checkpoint.validators.operations.wait import (
|
|
28
|
+
VALID_ACTIONS_FOR_WAIT,
|
|
29
|
+
)
|
|
30
|
+
from aws_durable_execution_sdk_python_testing.exceptions import (
|
|
31
|
+
InvalidParameterValueException,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ValidActionsByOperationTypeValidator:
|
|
36
|
+
"""Validates that the given action is valid for the given operation type."""
|
|
37
|
+
|
|
38
|
+
_VALID_ACTIONS_BY_OPERATION_TYPE: ClassVar[
|
|
39
|
+
dict[OperationType, frozenset[OperationAction]]
|
|
40
|
+
] = {
|
|
41
|
+
OperationType.STEP: VALID_ACTIONS_FOR_STEP,
|
|
42
|
+
OperationType.CONTEXT: VALID_ACTIONS_FOR_CONTEXT,
|
|
43
|
+
OperationType.WAIT: VALID_ACTIONS_FOR_WAIT,
|
|
44
|
+
OperationType.CALLBACK: VALID_ACTIONS_FOR_CALLBACK,
|
|
45
|
+
OperationType.CHAINED_INVOKE: VALID_ACTIONS_FOR_INVOKE,
|
|
46
|
+
OperationType.EXECUTION: VALID_ACTIONS_FOR_EXECUTION,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def validate(operation_type: OperationType, action: OperationAction) -> None:
|
|
51
|
+
"""Validate that the action is valid for the operation type."""
|
|
52
|
+
valid_actions = (
|
|
53
|
+
ValidActionsByOperationTypeValidator._VALID_ACTIONS_BY_OPERATION_TYPE.get(
|
|
54
|
+
operation_type
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if valid_actions is None:
|
|
59
|
+
msg_unknown_op: str = "Unknown operation type."
|
|
60
|
+
|
|
61
|
+
raise InvalidParameterValueException(msg_unknown_op)
|
|
62
|
+
|
|
63
|
+
if action not in valid_actions:
|
|
64
|
+
msg_invalid_action: str = "Invalid action for the given operation type."
|
|
65
|
+
|
|
66
|
+
raise InvalidParameterValueException(msg_invalid_action)
|