Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/deploy-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ jobs:
FUNCTION_NAME="${EXAMPLE_NAME_CLEAN}-Python"
fi

# Clean up existing function if present to avoid conflicts
echo "Cleaning up existing function if present..."
aws lambda delete-function \
--function-name "$FUNCTION_NAME" \
--endpoint-url "$LAMBDA_ENDPOINT" \
--region "$AWS_REGION" 2>/dev/null || echo "No existing function to clean up"

# Give AWS time to process the deletion
sleep 5

echo "Deploying ${{ matrix.example.name }} as $FUNCTION_NAME"
hatch run examples:deploy "${{ matrix.example.name }}" --function-name "$FUNCTION_NAME"

Expand Down Expand Up @@ -119,6 +129,10 @@ jobs:
# Run integration tests
hatch run test:examples-integration

# Wait for function to be ready
echo "Waiting for function to be active..."
aws lambda wait function-active --function-name "$QUALIFIED_FUNCTION_NAME" --endpoint-url "$LAMBDA_ENDPOINT" --region "$AWS_REGION"

- name: Invoke Lambda function - ${{ matrix.example.name }}
env:
LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT_BETA }}
Expand Down
2 changes: 1 addition & 1 deletion examples/test/test_wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def test_wait(durable_runner):
wait_ops = [op for op in result.operations if op.operation_type.value == "WAIT"]
assert len(wait_ops) == 1
wait_op = wait_ops[0]
assert wait_op.scheduled_timestamp is not None
assert wait_op.scheduled_end_timestamp is not None
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ def _create_wait_details(
"""Create WaitDetails from OperationUpdate."""
if update.operation_type == OperationType.WAIT and update.wait_options:
if current_operation and current_operation.wait_details:
scheduled_timestamp = current_operation.wait_details.scheduled_timestamp
scheduled_end_timestamp = (
current_operation.wait_details.scheduled_end_timestamp
)
else:
scheduled_timestamp = datetime.datetime.now(
scheduled_end_timestamp = datetime.datetime.now(
tz=datetime.UTC
) + timedelta(seconds=update.wait_options.wait_seconds)
return WaitDetails(scheduled_timestamp=scheduled_timestamp)
return WaitDetails(scheduled_end_timestamp=scheduled_end_timestamp)
return None

def _translate_update_to_operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ def process(
wait_seconds = (
update.wait_options.wait_seconds if update.wait_options else 0
)
scheduled_timestamp = datetime.now(UTC) + timedelta(
scheduled_end_timestamp = datetime.now(UTC) + timedelta(
seconds=wait_seconds
)

# Create WaitDetails with scheduled timestamp
wait_details = WaitDetails(scheduled_timestamp=scheduled_timestamp)
wait_details = WaitDetails(
scheduled_end_timestamp=scheduled_end_timestamp
)

# Create new operation with wait details
wait_operation = Operation(
Expand Down
18 changes: 9 additions & 9 deletions src/aws_durable_execution_sdk_python_testing/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ def events_to_operations(events: list[Event]) -> list[Operation]:
operation = replace(
operation,
wait_details=WaitDetails(
scheduled_timestamp=event.wait_started_details.scheduled_end_timestamp
scheduled_end_timestamp=event.wait_started_details.scheduled_end_timestamp
),
)

Expand Down Expand Up @@ -1783,8 +1783,8 @@ class ListDurableExecutionsByFunctionRequest:
qualifier: str | None = None
durable_execution_name: str | None = None
status_filter: list[str] | None = None
time_after: str | None = None
time_before: str | None = None
started_after: str | None = None
started_before: str | None = None
marker: str | None = None
max_items: int = 0
reverse_order: bool | None = None
Expand All @@ -1796,8 +1796,8 @@ def from_dict(cls, data: dict) -> ListDurableExecutionsByFunctionRequest:
qualifier=data.get("Qualifier"),
durable_execution_name=data.get("DurableExecutionName"),
status_filter=data.get("StatusFilter"),
time_after=data.get("TimeAfter"),
time_before=data.get("TimeBefore"),
started_after=data.get("StartedAfter"),
started_before=data.get("StartedBefore"),
marker=data.get("Marker"),
max_items=data.get("MaxItems", 0),
reverse_order=data.get("ReverseOrder"),
Expand All @@ -1811,10 +1811,10 @@ def to_dict(self) -> dict[str, Any]:
result["DurableExecutionName"] = self.durable_execution_name
if self.status_filter is not None:
result["StatusFilter"] = self.status_filter
if self.time_after is not None:
result["TimeAfter"] = self.time_after
if self.time_before is not None:
result["TimeBefore"] = self.time_before
if self.started_after is not None:
result["StartedAfter"] = self.started_after
if self.started_before is not None:
result["StartedBefore"] = self.started_before
if self.marker is not None:
result["Marker"] = self.marker
if self.max_items is not None:
Expand Down
6 changes: 3 additions & 3 deletions src/aws_durable_execution_sdk_python_testing/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def from_svc_operation(

@dataclass(frozen=True)
class WaitOperation(Operation):
scheduled_timestamp: datetime.datetime | None = None
scheduled_end_timestamp: datetime.datetime | None = None

@staticmethod
def from_svc_operation(
Expand All @@ -285,8 +285,8 @@ def from_svc_operation(
sub_type=operation.sub_type,
start_timestamp=operation.start_timestamp,
end_timestamp=operation.end_timestamp,
scheduled_timestamp=(
operation.wait_details.scheduled_timestamp
scheduled_end_timestamp=(
operation.wait_details.scheduled_end_timestamp
if operation.wait_details
else None
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,9 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse:
if status_filter := self._parse_query_param(request, "statusFilter"):
query_params["StatusFilter"] = [status_filter] # Convert to list
if time_after := self._parse_query_param(request, "timeAfter"):
query_params["TimeAfter"] = time_after
query_params["StartedAfter"] = time_after
if time_before := self._parse_query_param(request, "timeBefore"):
query_params["TimeBefore"] = time_before
query_params["StartedBefore"] = time_before
if marker := self._parse_query_param(request, "marker"):
query_params["Marker"] = marker
if max_items_str := self._parse_query_param(request, "maxItems"):
Expand Down Expand Up @@ -608,8 +608,8 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse:
status_filter=list_request.status_filter[0]
if list_request.status_filter
else None,
time_after=list_request.time_after,
time_before=list_request.time_before,
time_after=list_request.started_after,
time_before=list_request.started_before,
marker=list_request.marker,
max_items=list_request.max_items
if list_request.max_items > 0
Expand Down
6 changes: 3 additions & 3 deletions tests/checkpoint/processors/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_create_wait_details_with_current_operation():
processor = MockProcessor()
scheduled_time = datetime.datetime.now(tz=datetime.UTC)
current_op = Mock()
current_op.wait_details = WaitDetails(scheduled_timestamp=scheduled_time)
current_op.wait_details = WaitDetails(scheduled_end_timestamp=scheduled_time)

wait_options = WaitOptions(wait_seconds=30)
update = OperationUpdate(
Expand All @@ -333,7 +333,7 @@ def test_create_wait_details_with_current_operation():
result = processor.create_wait_details(update, current_op)

assert isinstance(result, WaitDetails)
assert result.scheduled_timestamp == scheduled_time
assert result.scheduled_end_timestamp == scheduled_time


def test_create_wait_details_without_current_operation():
Expand All @@ -349,7 +349,7 @@ def test_create_wait_details_without_current_operation():
result = processor.create_wait_details(update, None)

assert isinstance(result, WaitDetails)
assert result.scheduled_timestamp > datetime.datetime.now(tz=datetime.UTC)
assert result.scheduled_end_timestamp > datetime.datetime.now(tz=datetime.UTC)


def test_create_wait_details_non_wait_type():
Expand Down
4 changes: 2 additions & 2 deletions tests/checkpoint/processors/wait_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_process_start_action():
assert result.status == OperationStatus.STARTED
assert result.name == "test-wait"
assert result.wait_details is not None
assert result.wait_details.scheduled_timestamp > datetime.now(UTC)
assert result.wait_details.scheduled_end_timestamp > datetime.now(UTC)

assert len(notifier.wait_timer_calls) == 1
assert notifier.wait_timer_calls[0] == (execution_arn, "wait-123", 30)
Expand Down Expand Up @@ -269,7 +269,7 @@ def test_wait_details_created_correctly():
before_time = datetime.now(UTC)
result = processor.process(update, None, notifier, execution_arn)

assert result.wait_details.scheduled_timestamp > before_time
assert result.wait_details.scheduled_end_timestamp > before_time


def test_no_completed_or_failed_calls():
Expand Down
Loading
Loading