2020 ValidationError ,
2121)
2222from aws_durable_execution_sdk_python .identifier import OperationIdentifier
23- from aws_durable_execution_sdk_python .lambda_context import (
24- LambdaContext ,
25- make_dict_from_obj ,
26- )
2723from aws_durable_execution_sdk_python .lambda_service import OperationSubType
2824from aws_durable_execution_sdk_python .logger import Logger , LogInfo
2925from aws_durable_execution_sdk_python .operation .callback import (
@@ -149,32 +145,16 @@ def result(self) -> T | None:
149145 raise FatalError (msg )
150146
151147
152- # It really would be great NOT to have to inherit from the LambdaContext.
153- # lot of noise here that we're not actually using. Alternative is to include
154- # via composition rather than inheritance
155- class DurableContext (LambdaContext , DurableContextProtocol ):
148+ class DurableContext (DurableContextProtocol ):
156149 def __init__ (
157150 self ,
158151 state : ExecutionState ,
152+ lambda_context : Any | None = None ,
159153 parent_id : str | None = None ,
160154 logger : Logger | None = None ,
161- # LambdaContext members follow
162- invoke_id = None ,
163- client_context = None ,
164- cognito_identity = None ,
165- epoch_deadline_time_in_ms = 0 ,
166- invoked_function_arn = None ,
167- tenant_id = None ,
168155 ) -> None :
169- super ().__init__ (
170- invoke_id = invoke_id ,
171- client_context = client_context ,
172- cognito_identity = cognito_identity ,
173- epoch_deadline_time_in_ms = epoch_deadline_time_in_ms ,
174- invoked_function_arn = invoked_function_arn ,
175- tenant_id = tenant_id ,
176- )
177156 self .state : ExecutionState = state
157+ self .lambda_context = lambda_context
178158 self ._parent_id : str | None = parent_id
179159 self ._step_counter : OrderedCounter = OrderedCounter ()
180160
@@ -195,37 +175,26 @@ def __init__(
195175 @staticmethod
196176 def from_lambda_context (
197177 state : ExecutionState ,
198- lambda_context : LambdaContext ,
178+ lambda_context : Any ,
199179 ):
200180 return DurableContext (
201181 state = state ,
182+ lambda_context = lambda_context ,
202183 parent_id = None ,
203- invoke_id = lambda_context .aws_request_id ,
204- client_context = make_dict_from_obj (lambda_context .client_context ),
205- cognito_identity = make_dict_from_obj (lambda_context .identity ),
206- # not great to have to use the private-ish accessor here, but for the moment not messing with LambdaContext signature
207- epoch_deadline_time_in_ms = lambda_context ._epoch_deadline_time_in_ms , # noqa: SLF001
208- invoked_function_arn = lambda_context .invoked_function_arn ,
209- tenant_id = lambda_context .tenant_id ,
210184 )
211185
212186 def create_child_context (self , parent_id : str ) -> DurableContext :
213187 """Create a child context from the given parent."""
214188 logger .debug ("Creating child context for parent %s" , parent_id )
215189 return DurableContext (
216190 state = self .state ,
191+ lambda_context = self .lambda_context ,
217192 parent_id = parent_id ,
218193 logger = self .logger .with_log_info (
219194 LogInfo (
220195 execution_arn = self .state .durable_execution_arn , parent_id = parent_id
221196 )
222197 ),
223- invoke_id = self .aws_request_id ,
224- client_context = make_dict_from_obj (self .client_context ),
225- cognito_identity = make_dict_from_obj (self .identity ),
226- epoch_deadline_time_in_ms = self ._epoch_deadline_time_in_ms ,
227- invoked_function_arn = self .invoked_function_arn ,
228- tenant_id = self .tenant_id ,
229198 )
230199
231200 # endregion factories
0 commit comments