Skip to content

Commit ffa3e28

Browse files
committed
remove dead code
1 parent bfe280a commit ffa3e28

4 files changed

Lines changed: 34 additions & 55 deletions

File tree

src/aws_durable_execution_sdk_python_testing/executor.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
CallbackTimeoutType,
1717
ErrorObject,
1818
Operation,
19+
OperationAction,
1920
OperationUpdate,
2021
OperationStatus,
2122
OperationType,
@@ -1133,11 +1134,6 @@ def _checkpoint_chained_invoke_succeed(
11331134
result: str | None,
11341135
) -> None:
11351136
"""Checkpoint a successful chained invoke."""
1136-
from aws_durable_execution_sdk_python.lambda_service import (
1137-
OperationAction,
1138-
OperationUpdate,
1139-
)
1140-
11411137
execution = self._store.load(execution_arn)
11421138
checkpoint_token = execution.get_new_checkpoint_token()
11431139

@@ -1163,11 +1159,6 @@ def _checkpoint_chained_invoke_fail(
11631159
error: ErrorObject,
11641160
) -> None:
11651161
"""Checkpoint a failed chained invoke."""
1166-
from aws_durable_execution_sdk_python.lambda_service import (
1167-
OperationAction,
1168-
OperationUpdate,
1169-
)
1170-
11711162
execution = self._store.load(execution_arn)
11721163
checkpoint_token = execution.get_new_checkpoint_token()
11731164

src/aws_durable_execution_sdk_python_testing/runner.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
import aws_durable_execution_sdk_python
2020
import boto3 # type: ignore
21+
import requests # type: ignore
2122
from botocore.exceptions import ClientError # type: ignore
2223
from aws_durable_execution_sdk_python.execution import (
2324
InvocationStatus,
2425
durable_execution,
2526
)
2627
from aws_durable_execution_sdk_python.lambda_service import (
2728
ErrorObject,
29+
OperationAction,
2830
OperationPayload,
2931
OperationStatus,
3032
OperationSubType,
@@ -348,8 +350,6 @@ def from_svc_operation(
348350
class InvokeOperation(Operation):
349351
result: OperationPayload | None = None
350352
error: ErrorObject | None = None
351-
function_name: str | None = None
352-
input_payload: str | None = None
353353

354354
@staticmethod
355355
def from_svc_operation(
@@ -360,14 +360,6 @@ def from_svc_operation(
360360
msg: str = f"Expected INVOKE operation, got {operation.operation_type}"
361361
raise InvalidParameterValueException(msg)
362362

363-
# Extract function_name from chained_invoke_options if available
364-
function_name: str | None = None
365-
input_payload: str | None = None
366-
if operation.chained_invoke_details:
367-
# Note: function_name and input_payload would need to be added to
368-
# ChainedInvokeDetails in the SDK, or extracted from operation metadata
369-
pass
370-
371363
return InvokeOperation(
372364
operation_id=operation.operation_id,
373365
operation_type=operation.operation_type,
@@ -383,8 +375,6 @@ def from_svc_operation(
383375
error=operation.chained_invoke_details.error
384376
if operation.chained_invoke_details
385377
else None,
386-
function_name=function_name,
387-
input_payload=input_payload,
388378
)
389379

390380

@@ -916,7 +906,6 @@ def register_endpoint(self, function_name: str, endpoint: str) -> None:
916906
Raises:
917907
InvalidParameterValueException: If function_name is empty/None or endpoint is empty/None
918908
"""
919-
import requests
920909

921910
if not function_name:
922911
raise InvalidParameterValueException("function_name is required")

tests/e2e/chained_invoke_test.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ def test_handler_registration_and_retrieval(self):
5151
def dummy_handler(event, context):
5252
return {"status": "ok"}
5353

54-
def child_handler(payload: str | None) -> str | None:
55-
return json.dumps({"result": "child_result"})
54+
def child_handler(event, context):
55+
return {"result": "child_result"}
5656

5757
with DurableFunctionTestRunner(handler=dummy_handler) as runner:
5858
# Register handler
5959
runner.register_handler("child-function", child_handler)
6060

61-
# Verify handler can be retrieved
61+
# Verify handler can be retrieved (returns wrapped marshalled handler)
6262
retrieved = runner.get_handler("child-function")
63-
assert retrieved is child_handler
63+
assert retrieved is not None
6464

6565
# Verify non-existent handler returns None
6666
assert runner.get_handler("non-existent") is None
@@ -76,19 +76,19 @@ def dummy_handler(event, context):
7676
return {"status": "ok"}
7777

7878
handlers = {
79-
"handler-a": lambda p: '{"result": "a"}',
80-
"handler-b": lambda p: '{"result": "b"}',
81-
"handler-c": lambda p: '{"result": "c"}',
79+
"handler-a": lambda event, context: {"result": "a"},
80+
"handler-b": lambda event, context: {"result": "b"},
81+
"handler-c": lambda event, context: {"result": "c"},
8282
}
8383

8484
with DurableFunctionTestRunner(handler=dummy_handler) as runner:
8585
# Register all handlers
8686
for name, handler in handlers.items():
8787
runner.register_handler(name, handler)
8888

89-
# Verify all handlers are retrievable
90-
for name, handler in handlers.items():
91-
assert runner.get_handler(name) is handler
89+
# Verify all handlers are retrievable (returns wrapped marshalled handlers)
90+
for name in handlers:
91+
assert runner.get_handler(name) is not None
9292

9393
def test_handler_registration_validation(self):
9494
"""
@@ -360,22 +360,22 @@ def test_non_durable_function_synchronous_execution(self):
360360
"""
361361
execution_order = []
362362

363-
def child_handler(payload: str | None) -> str | None:
363+
def child_handler(event, context):
364364
execution_order.append("child_executed")
365-
data = json.loads(payload) if payload else {}
366-
return json.dumps({"processed": data.get("value", 0) * 2})
365+
value = event.get("value", 0) if event else 0
366+
return {"processed": value * 2}
367367

368368
def dummy_handler(event, context):
369369
return {"status": "ok"}
370370

371371
with DurableFunctionTestRunner(handler=dummy_handler) as runner:
372372
runner.register_handler("sync-child", child_handler)
373373

374-
# Get the handler and invoke it directly (simulating synchronous execution)
374+
# Get the marshalled handler and invoke it directly (simulating synchronous execution)
375375
handler = runner.get_handler("sync-child")
376376
assert handler is not None
377377

378-
# Execute synchronously
378+
# Execute synchronously (marshalled handler takes JSON string payload)
379379
result = handler('{"value": 21}')
380380
execution_order.append("after_child")
381381

@@ -390,17 +390,15 @@ def test_non_durable_function_result_serialization(self):
390390
_Requirements: 8.2_
391391
"""
392392

393-
def child_handler(payload: str | None) -> str | None:
394-
# Handler returns serialized JSON string
395-
return json.dumps(
396-
{
397-
"string": "value",
398-
"number": 123,
399-
"boolean": True,
400-
"array": [1, 2, 3],
401-
"nested": {"key": "value"},
402-
}
403-
)
393+
def child_handler(event, context):
394+
# Handler returns dict (Lambda-style), marshalled handler serializes it
395+
return {
396+
"string": "value",
397+
"number": 123,
398+
"boolean": True,
399+
"array": [1, 2, 3],
400+
"nested": {"key": "value"},
401+
}
404402

405403
def dummy_handler(event, context):
406404
return {"status": "ok"}
@@ -411,7 +409,7 @@ def dummy_handler(event, context):
411409
handler = runner.get_handler("serializing-child")
412410
result = handler(None)
413411

414-
# Verify result is valid JSON
412+
# Verify result is valid JSON (marshalled handler serializes the dict)
415413
parsed = json.loads(result)
416414
assert parsed["string"] == "value"
417415
assert parsed["number"] == 123
@@ -426,7 +424,7 @@ def test_non_durable_function_exception_capture(self):
426424
_Requirements: 8.3_
427425
"""
428426

429-
def failing_child(payload: str | None) -> str | None:
427+
def failing_child(event, context):
430428
raise RuntimeError("Child function failed")
431429

432430
def dummy_handler(event, context):
@@ -437,6 +435,6 @@ def dummy_handler(event, context):
437435

438436
handler = runner.get_handler("failing-child")
439437

440-
# Verify exception is raised
438+
# Verify exception is raised (marshalled handler propagates exceptions)
441439
with pytest.raises(RuntimeError, match="Child function failed"):
442440
handler('{"input": "data"}')

tests/runner_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,7 @@ def test_local_and_cloud_runner_result_structure_consistency():
23382338

23392339
# Check DurableFunctionTestResult has expected attributes
23402340
for attr in result_attrs:
2341-
assert hasattr(DurableFunctionTestResult, attr) or attr in DurableFunctionTestResult.__dataclass_fields__, (
2342-
f"DurableFunctionTestResult should have '{attr}' attribute"
2343-
)
2341+
assert (
2342+
hasattr(DurableFunctionTestResult, attr)
2343+
or attr in DurableFunctionTestResult.__dataclass_fields__
2344+
), f"DurableFunctionTestResult should have '{attr}' attribute"

0 commit comments

Comments
 (0)