Skip to content

Commit 89f2f6d

Browse files
author
Rares Polenciuc
committed
fix: pass endpoint to invoker
1 parent be79e91 commit 89f2f6d

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/aws_durable_execution_sdk_python_testing/executor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,9 @@ async def invoke() -> None:
770770
self._store.save(execution)
771771

772772
response: DurableExecutionInvocationOutput = self._invoker.invoke(
773-
execution.start_input.function_name, invocation_input
773+
execution.start_input.function_name,
774+
invocation_input,
775+
execution.start_input.lambda_endpoint,
774776
)
775777

776778
# Reload execution after invocation in case it was completed via checkpoint

src/aws_durable_execution_sdk_python_testing/invoker.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from aws_durable_execution_sdk_python_testing.exceptions import (
1717
DurableFunctionsTestError,
18+
ServiceException,
1819
)
1920
from aws_durable_execution_sdk_python_testing.model import LambdaContext
2021

@@ -63,6 +64,7 @@ def invoke(
6364
self,
6465
function_name: str,
6566
input: DurableExecutionInvocationInput,
67+
endpoint_url: str | None = None,
6668
) -> DurableExecutionInvocationOutput: ... # pragma: no cover
6769

6870
def update_endpoint(
@@ -93,6 +95,7 @@ def invoke(
9395
self,
9496
function_name: str, # noqa: ARG002
9597
input: DurableExecutionInvocationInput,
98+
endpoint_url: str | None = None, # noqa: ARG002
9699
) -> DurableExecutionInvocationOutput:
97100
# TODO: reasses if function_name will be used in future
98101
input_with_client = DurableExecutionInvocationInputWithClient.from_durable_execution_invocation_input(
@@ -140,19 +143,19 @@ def update_endpoint(self, endpoint_url: str, region_name: str) -> None:
140143
self._current_endpoint = endpoint_url
141144

142145
def _get_client_for_execution(
143-
self, durable_execution_arn: str, lambda_endpoint: str | None = None
146+
self,
147+
durable_execution_arn: str,
148+
lambda_endpoint: str | None = None,
149+
region_name: str | None = None,
144150
) -> Any:
145151
"""Get the appropriate client for this execution."""
146152
# Use provided endpoint or fall back to cached endpoint for this execution
147153
if lambda_endpoint:
148-
# Client should already exist from update_endpoint() call
149154
if lambda_endpoint not in self._endpoint_clients:
150-
from aws_durable_execution_sdk_python_testing.exceptions import (
151-
ServiceException,
152-
)
153-
154-
raise ServiceException(
155-
f"Lambda endpoint {lambda_endpoint} not configured. update_endpoint() must be called first."
155+
self._endpoint_clients[lambda_endpoint] = boto3.client(
156+
"lambdainternal",
157+
endpoint_url=lambda_endpoint,
158+
region_name=region_name or "us-east-1",
156159
)
157160
return self._endpoint_clients[lambda_endpoint]
158161

@@ -188,12 +191,14 @@ def invoke(
188191
self,
189192
function_name: str,
190193
input: DurableExecutionInvocationInput,
194+
endpoint_url: str | None = None,
191195
) -> DurableExecutionInvocationOutput:
192196
"""Invoke AWS Lambda function and return durable execution result.
193197
194198
Args:
195199
function_name: Name of the Lambda function to invoke
196200
input: Durable execution invocation input
201+
endpoint_url: Lambda endpoint url
197202
198203
Returns:
199204
DurableExecutionInvocationOutput: Result of the function execution
@@ -214,7 +219,9 @@ def invoke(
214219
raise InvalidParameterValueException(msg)
215220

216221
# Get the client for this execution
217-
client = self._get_client_for_execution(input.durable_execution_arn)
222+
client = self._get_client_for_execution(
223+
input.durable_execution_arn, endpoint_url
224+
)
218225

219226
try:
220227
# Invoke AWS Lambda function using standard invoke method

tests/executor_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def test_invoke_handler_success(
645645
mock_invoker.create_invocation_input.assert_called_once_with(
646646
execution=mock_execution
647647
)
648-
mock_invoker.invoke.assert_called_once_with("test-function", mock_invocation_input)
648+
mock_invoker.invoke.assert_called_once_with("test-function", mock_invocation_input, None)
649649

650650

651651
def test_invoke_handler_execution_already_complete(

0 commit comments

Comments
 (0)