Skip to content

Commit a71e9eb

Browse files
FullyTypedAstraea Quinn S
authored andcommitted
fix: Rename durable_handler to durable_execution
- renamed the decorator according to changes - kept durable_handler for compat reasons to avoid needing to change test framework
1 parent dfb5bd6 commit a71e9eb

File tree

4 files changed

+42
-34
lines changed

4 files changed

+42
-34
lines changed

src/aws_durable_execution_sdk_python/execution.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import logging
55
from dataclasses import dataclass
66
from enum import Enum
7+
from functools import wraps
78
from typing import TYPE_CHECKING, Any
9+
from warnings import deprecated
810

911
from aws_durable_execution_sdk_python.context import DurableContext, ExecutionState
1012
from aws_durable_execution_sdk_python.exceptions import (
@@ -187,7 +189,7 @@ def create_succeeded(cls, result: str) -> DurableExecutionInvocationOutput:
187189
# endregion Invocation models
188190

189191

190-
def durable_handler(
192+
def durable_execution(
191193
func: Callable[[Any, DurableContext], Any],
192194
) -> Callable[[Any, LambdaContext], Any]:
193195
logger.debug("Starting durable execution handler...")
@@ -308,3 +310,9 @@ def wrapper(event: Any, context: LambdaContext) -> MutableMapping[str, Any]:
308310
).to_dict()
309311

310312
return wrapper
313+
314+
315+
@deprecated("Use `durable_execution` instead.")
316+
@wraps(durable_execution)
317+
def durable_handler(*args, **kwargs):
318+
return durable_execution(*args, **kwargs)

src/aws_durable_execution_sdk_python/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def get_checkpoint_result(self, checkpoint_id: str) -> CheckpointedResult:
219219
Note this does not invoke the Durable Functions API. It only checks
220220
against the checkpoints currently saved in ExecutionState. The current
221221
saved checkpoints are from InitialExecutionState as retrieved
222-
at the start of the current execution/replay (see execution.durable_handler),
222+
at the start of the current execution/replay (see execution.durable_execution),
223223
and from each create_checkpoint response.
224224
225225
Args:

tests/e2e/execution_int_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313
from aws_durable_execution_sdk_python.execution import (
1414
InvocationStatus,
15-
durable_handler,
15+
durable_execution,
1616
)
1717

1818
# LambdaContext no longer needed - using duck typing
@@ -41,7 +41,7 @@ def step_no_args(step_context: StepContext) -> str:
4141
def step_with_args(step_context: StepContext, a: int, b: str) -> str:
4242
return f"from step {a} {b}"
4343

44-
@durable_handler
44+
@durable_execution
4545
def my_handler(event, context: DurableContext) -> list[str]:
4646
results: list[str] = []
4747
result: str = context.step(step_with_args(a=123, b="str"))
@@ -138,7 +138,7 @@ def mystep(step_context: StepContext, a: int, b: str) -> str:
138138
step_context.logger.info("from step %s %s", a, b)
139139
return "result"
140140

141-
@durable_handler
141+
@durable_execution
142142
def my_handler(event, context: DurableContext):
143143
context.set_logger(my_logger)
144144
result: str = context.step(mystep(a=123, b="str"))
@@ -232,7 +232,7 @@ def func(child_context: DurableContext, a: int, b: int):
232232
mock_inside_child(a, b)
233233
child_context.wait(1)
234234

235-
@durable_handler
235+
@durable_execution
236236
def my_handler(event, context):
237237
context.run_in_child_context(func(10, 20))
238238

@@ -325,7 +325,7 @@ class CustomError(Exception):
325325
def test_wait_not_caught_by_exception():
326326
"""Do not catch Suspend exceptions."""
327327

328-
@durable_handler
328+
@durable_execution
329329
def my_handler(event: Any, context: DurableContext):
330330
try:
331331
context.wait(1)

tests/execution_test.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
DurableExecutionInvocationInputWithClient,
1515
InitialExecutionState,
1616
InvocationStatus,
17-
durable_handler,
17+
durable_execution,
1818
)
1919

2020
# LambdaContext no longer needed - using duck typing
@@ -266,11 +266,11 @@ def test_operation_to_dict_minimal():
266266

267267
# endregion Models
268268

269-
# region durable_handler
269+
# region durable_execution
270270

271271

272-
def test_durable_handler_client_selection_env_normal_result():
273-
"""Test durable_handler selects correct client from environment."""
272+
def test_durable_execution_client_selection_env_normal_result():
273+
"""Test durable_execution selects correct client from environment."""
274274
with patch(
275275
"aws_durable_execution_sdk_python.execution.LambdaClient"
276276
) as mock_lambda_client:
@@ -284,7 +284,7 @@ def test_durable_handler_client_selection_env_normal_result():
284284
)
285285
mock_client.checkpoint.return_value = mock_output
286286

287-
@durable_handler
287+
@durable_execution
288288
def test_handler(event: Any, context: DurableContext) -> dict:
289289
return {"result": "success"}
290290

@@ -322,8 +322,8 @@ def test_handler(event: Any, context: DurableContext) -> dict:
322322
mock_client.checkpoint.assert_not_called()
323323

324324

325-
def test_durable_handler_client_selection_env_large_result():
326-
"""Test durable_handler selects correct client from environment."""
325+
def test_durable_execution_client_selection_env_large_result():
326+
"""Test durable_execution selects correct client from environment."""
327327
with patch(
328328
"aws_durable_execution_sdk_python.execution.LambdaClient"
329329
) as mock_lambda_client:
@@ -337,7 +337,7 @@ def test_durable_handler_client_selection_env_large_result():
337337
)
338338
mock_client.checkpoint.return_value = mock_output
339339

340-
@durable_handler
340+
@durable_execution
341341
def test_handler(event: Any, context: DurableContext) -> dict:
342342
return {"result": LARGE_RESULT}
343343

@@ -375,8 +375,8 @@ def test_handler(event: Any, context: DurableContext) -> dict:
375375
mock_client.checkpoint.assert_called_once()
376376

377377

378-
def test_durable_handler_with_injected_client_success_normal_result():
379-
"""Test durable_handler uses injected DurableServiceClient for successful execution."""
378+
def test_durable_execution_with_injected_client_success_normal_result():
379+
"""Test durable_execution uses injected DurableServiceClient for successful execution."""
380380
mock_client = Mock(spec=DurableServiceClient)
381381

382382
# Mock successful checkpoint
@@ -386,7 +386,7 @@ def test_durable_handler_with_injected_client_success_normal_result():
386386
)
387387
mock_client.checkpoint.return_value = mock_output
388388

389-
@durable_handler
389+
@durable_execution
390390
def test_handler(event: Any, context: DurableContext) -> dict:
391391
return {"result": "success"}
392392

@@ -423,8 +423,8 @@ def test_handler(event: Any, context: DurableContext) -> dict:
423423
mock_client.checkpoint.assert_not_called()
424424

425425

426-
def test_durable_handler_with_injected_client_success_large_result():
427-
"""Test durable_handler uses injected DurableServiceClient for successful execution."""
426+
def test_durable_execution_with_injected_client_success_large_result():
427+
"""Test durable_execution uses injected DurableServiceClient for successful execution."""
428428
mock_client = Mock(spec=DurableServiceClient)
429429

430430
# Mock successful checkpoint
@@ -434,7 +434,7 @@ def test_durable_handler_with_injected_client_success_large_result():
434434
)
435435
mock_client.checkpoint.return_value = mock_output
436436

437-
@durable_handler
437+
@durable_execution
438438
def test_handler(event: Any, context: DurableContext) -> dict:
439439
return {"result": LARGE_RESULT}
440440

@@ -479,8 +479,8 @@ def test_handler(event: Any, context: DurableContext) -> dict:
479479
assert json.loads(updates[0].payload) == {"result": LARGE_RESULT}
480480

481481

482-
def test_durable_handler_with_injected_client_failure():
483-
"""Test durable_handler uses injected DurableServiceClient for failed execution."""
482+
def test_durable_execution_with_injected_client_failure():
483+
"""Test durable_execution uses injected DurableServiceClient for failed execution."""
484484
mock_client = Mock(spec=DurableServiceClient)
485485

486486
# Mock successful checkpoint for failure
@@ -490,7 +490,7 @@ def test_durable_handler_with_injected_client_failure():
490490
)
491491
mock_client.checkpoint.return_value = mock_output
492492

493-
@durable_handler
493+
@durable_execution
494494
def test_handler(event: Any, context: DurableContext) -> dict:
495495
msg = "Test error"
496496
raise ValueError(msg)
@@ -535,14 +535,14 @@ def test_handler(event: Any, context: DurableContext) -> dict:
535535
assert updates[0].error.type == "ValueError"
536536

537537

538-
def test_durable_handler_checkpoint_error_propagation():
539-
"""Test durable_handler propagates CheckpointError from DurableServiceClient."""
538+
def test_durable_execution_checkpoint_error_propagation():
539+
"""Test durable_execution propagates CheckpointError from DurableServiceClient."""
540540
mock_client = Mock(spec=DurableServiceClient)
541541

542542
# Mock checkpoint to raise CheckpointError
543543
mock_client.checkpoint.side_effect = CheckpointError("Checkpoint failed")
544544

545-
@durable_handler
545+
@durable_execution
546546
def test_handler(event: Any, context: DurableContext) -> dict:
547547
return {"result": LARGE_RESULT}
548548

@@ -575,11 +575,11 @@ def test_handler(event: Any, context: DurableContext) -> dict:
575575
test_handler(invocation_input, lambda_context)
576576

577577

578-
def test_durable_handler_fatal_error_handling():
579-
"""Test durable_handler handles FatalError correctly."""
578+
def test_durable_execution_fatal_error_handling():
579+
"""Test durable_execution handles FatalError correctly."""
580580
mock_client = Mock(spec=DurableServiceClient)
581581

582-
@durable_handler
582+
@durable_execution
583583
def test_handler(event: Any, context: DurableContext) -> dict:
584584
msg = "Fatal error occurred"
585585
raise FatalError(msg)
@@ -615,8 +615,8 @@ def test_handler(event: Any, context: DurableContext) -> dict:
615615
assert "Fatal error occurred" in result["Error"]["ErrorMessage"]
616616

617617

618-
def test_durable_handler_client_selection_local_runner():
619-
"""Test durable_handler selects correct client for local runner."""
618+
def test_durable_execution_client_selection_local_runner():
619+
"""Test durable_execution selects correct client for local runner."""
620620
with patch(
621621
"aws_durable_execution_sdk_python.execution.LambdaClient"
622622
) as mock_lambda_client:
@@ -630,7 +630,7 @@ def test_durable_handler_client_selection_local_runner():
630630
)
631631
mock_client.checkpoint.return_value = mock_output
632632

633-
@durable_handler
633+
@durable_execution
634634
def test_handler(event: Any, context: DurableContext) -> dict:
635635
return {"result": "success"}
636636

@@ -666,4 +666,4 @@ def test_handler(event: Any, context: DurableContext) -> dict:
666666
mock_lambda_client.initialize_local_runner_client.assert_called_once()
667667

668668

669-
# endregion durable_handler
669+
# endregion durable_execution

0 commit comments

Comments
 (0)