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.
Files changed (52) hide show
  1. aws_durable_execution_sdk_python_testing/__about__.py +4 -0
  2. aws_durable_execution_sdk_python_testing/__init__.py +20 -0
  3. aws_durable_execution_sdk_python_testing/checkpoint/__init__.py +1 -0
  4. aws_durable_execution_sdk_python_testing/checkpoint/processor.py +101 -0
  5. aws_durable_execution_sdk_python_testing/checkpoint/processors/__init__.py +1 -0
  6. aws_durable_execution_sdk_python_testing/checkpoint/processors/base.py +199 -0
  7. aws_durable_execution_sdk_python_testing/checkpoint/processors/callback.py +89 -0
  8. aws_durable_execution_sdk_python_testing/checkpoint/processors/context.py +59 -0
  9. aws_durable_execution_sdk_python_testing/checkpoint/processors/execution.py +52 -0
  10. aws_durable_execution_sdk_python_testing/checkpoint/processors/step.py +124 -0
  11. aws_durable_execution_sdk_python_testing/checkpoint/processors/wait.py +95 -0
  12. aws_durable_execution_sdk_python_testing/checkpoint/transformer.py +104 -0
  13. aws_durable_execution_sdk_python_testing/checkpoint/validators/__init__.py +1 -0
  14. aws_durable_execution_sdk_python_testing/checkpoint/validators/checkpoint.py +242 -0
  15. aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/__init__.py +1 -0
  16. aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/callback.py +45 -0
  17. aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/context.py +73 -0
  18. aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/execution.py +47 -0
  19. aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/invoke.py +56 -0
  20. aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/step.py +106 -0
  21. aws_durable_execution_sdk_python_testing/checkpoint/validators/operations/wait.py +54 -0
  22. aws_durable_execution_sdk_python_testing/checkpoint/validators/transitions.py +66 -0
  23. aws_durable_execution_sdk_python_testing/cli.py +501 -0
  24. aws_durable_execution_sdk_python_testing/client.py +50 -0
  25. aws_durable_execution_sdk_python_testing/exceptions.py +288 -0
  26. aws_durable_execution_sdk_python_testing/execution.py +440 -0
  27. aws_durable_execution_sdk_python_testing/executor.py +1214 -0
  28. aws_durable_execution_sdk_python_testing/invoker.py +327 -0
  29. aws_durable_execution_sdk_python_testing/model.py +3267 -0
  30. aws_durable_execution_sdk_python_testing/observer.py +144 -0
  31. aws_durable_execution_sdk_python_testing/py.typed +1 -0
  32. aws_durable_execution_sdk_python_testing/runner.py +1185 -0
  33. aws_durable_execution_sdk_python_testing/scheduler.py +246 -0
  34. aws_durable_execution_sdk_python_testing/stores/__init__.py +1 -0
  35. aws_durable_execution_sdk_python_testing/stores/base.py +147 -0
  36. aws_durable_execution_sdk_python_testing/stores/filesystem.py +104 -0
  37. aws_durable_execution_sdk_python_testing/stores/memory.py +38 -0
  38. aws_durable_execution_sdk_python_testing/stores/sqlite.py +283 -0
  39. aws_durable_execution_sdk_python_testing/token.py +49 -0
  40. aws_durable_execution_sdk_python_testing/web/__init__.py +1 -0
  41. aws_durable_execution_sdk_python_testing/web/errors.py +8 -0
  42. aws_durable_execution_sdk_python_testing/web/handlers.py +807 -0
  43. aws_durable_execution_sdk_python_testing/web/models.py +266 -0
  44. aws_durable_execution_sdk_python_testing/web/routes.py +684 -0
  45. aws_durable_execution_sdk_python_testing/web/serialization.py +245 -0
  46. aws_durable_execution_sdk_python_testing/web/server.py +243 -0
  47. aws_durable_execution_sdk_python_testing-1.0.0.dist-info/METADATA +221 -0
  48. aws_durable_execution_sdk_python_testing-1.0.0.dist-info/RECORD +52 -0
  49. aws_durable_execution_sdk_python_testing-1.0.0.dist-info/WHEEL +4 -0
  50. aws_durable_execution_sdk_python_testing-1.0.0.dist-info/entry_points.txt +2 -0
  51. aws_durable_execution_sdk_python_testing-1.0.0.dist-info/licenses/LICENSE +175 -0
  52. aws_durable_execution_sdk_python_testing-1.0.0.dist-info/licenses/NOTICE +1 -0
@@ -0,0 +1,144 @@
1
+ """Checkpoint processors can notify the Execution of notable event state changes. Observer pattern."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import threading
6
+ from abc import ABC, abstractmethod
7
+ from typing import TYPE_CHECKING
8
+
9
+ from aws_durable_execution_sdk_python_testing.token import CallbackToken
10
+
11
+ if TYPE_CHECKING:
12
+ from collections.abc import Callable
13
+
14
+ from aws_durable_execution_sdk_python.lambda_service import (
15
+ ErrorObject,
16
+ CallbackOptions,
17
+ )
18
+
19
+
20
+ class ExecutionObserver(ABC):
21
+ """Observer for execution lifecycle events."""
22
+
23
+ @abstractmethod
24
+ def on_completed(self, execution_arn: str, result: str | None = None) -> None:
25
+ """Called when execution completes successfully."""
26
+
27
+ @abstractmethod
28
+ def on_failed(self, execution_arn: str, error: ErrorObject) -> None:
29
+ """Called when execution fails."""
30
+
31
+ @abstractmethod
32
+ def on_timed_out(self, execution_arn: str, error: ErrorObject) -> None:
33
+ """Called when execution times out."""
34
+
35
+ @abstractmethod
36
+ def on_stopped(self, execution_arn: str, error: ErrorObject) -> None:
37
+ """Called when execution is stopped."""
38
+
39
+ @abstractmethod
40
+ def on_wait_timer_scheduled(
41
+ self, execution_arn: str, operation_id: str, delay: float
42
+ ) -> None:
43
+ """Called when wait timer scheduled."""
44
+
45
+ @abstractmethod
46
+ def on_step_retry_scheduled(
47
+ self, execution_arn: str, operation_id: str, delay: float
48
+ ) -> None:
49
+ """Called when step retry scheduled."""
50
+
51
+ @abstractmethod
52
+ def on_callback_created(
53
+ self,
54
+ execution_arn: str,
55
+ operation_id: str,
56
+ callback_options: CallbackOptions | None,
57
+ callback_token: CallbackToken,
58
+ ) -> None:
59
+ """Called when callback is created."""
60
+
61
+
62
+ class ExecutionNotifier:
63
+ """Notifies observers about execution events. Thread-safe."""
64
+
65
+ def __init__(self) -> None:
66
+ self._observers: list[ExecutionObserver] = []
67
+ self._lock = threading.RLock()
68
+
69
+ def add_observer(self, observer: ExecutionObserver) -> None:
70
+ """Add an observer to be notified of execution events."""
71
+ with self._lock:
72
+ self._observers.append(observer)
73
+
74
+ def _notify_observers(self, method: Callable, *args, **kwargs) -> None:
75
+ """Notify all observers by calling the specified method."""
76
+ with self._lock:
77
+ observers = self._observers.copy()
78
+ for observer in observers:
79
+ getattr(observer, method.__name__)(*args, **kwargs)
80
+
81
+ # region event emitters
82
+ def notify_completed(self, execution_arn: str, result: str | None = None) -> None:
83
+ """Notify observers about execution completion."""
84
+ self._notify_observers(
85
+ ExecutionObserver.on_completed, execution_arn=execution_arn, result=result
86
+ )
87
+
88
+ def notify_failed(self, execution_arn: str, error: ErrorObject) -> None:
89
+ """Notify observers about execution failure."""
90
+ self._notify_observers(
91
+ ExecutionObserver.on_failed, execution_arn=execution_arn, error=error
92
+ )
93
+
94
+ def notify_timed_out(self, execution_arn: str, error: ErrorObject) -> None:
95
+ """Notify observers about execution timeout."""
96
+ self._notify_observers(
97
+ ExecutionObserver.on_timed_out, execution_arn=execution_arn, error=error
98
+ )
99
+
100
+ def notify_stopped(self, execution_arn: str, error: ErrorObject) -> None:
101
+ """Notify observers about execution being stopped."""
102
+ self._notify_observers(
103
+ ExecutionObserver.on_stopped, execution_arn=execution_arn, error=error
104
+ )
105
+
106
+ def notify_wait_timer_scheduled(
107
+ self, execution_arn: str, operation_id: str, delay: float
108
+ ) -> None:
109
+ """Notify observers about wait timer scheduling."""
110
+ self._notify_observers(
111
+ ExecutionObserver.on_wait_timer_scheduled,
112
+ execution_arn=execution_arn,
113
+ operation_id=operation_id,
114
+ delay=delay,
115
+ )
116
+
117
+ def notify_step_retry_scheduled(
118
+ self, execution_arn: str, operation_id: str, delay: float
119
+ ) -> None:
120
+ """Notify observers about step retry scheduling."""
121
+ self._notify_observers(
122
+ ExecutionObserver.on_step_retry_scheduled,
123
+ execution_arn=execution_arn,
124
+ operation_id=operation_id,
125
+ delay=delay,
126
+ )
127
+
128
+ def notify_callback_created(
129
+ self,
130
+ execution_arn: str,
131
+ operation_id: str,
132
+ callback_options: CallbackOptions | None,
133
+ callback_token: CallbackToken,
134
+ ) -> None:
135
+ """Notify observers about callback creation."""
136
+ self._notify_observers(
137
+ ExecutionObserver.on_callback_created,
138
+ execution_arn=execution_arn,
139
+ operation_id=operation_id,
140
+ callback_options=callback_options,
141
+ callback_token=callback_token,
142
+ )
143
+
144
+ # endregion event emitters
@@ -0,0 +1 @@
1
+ # Marker file that indicates this package supports typing