Skip to content

Commit 5cafcf4

Browse files
authored
fix: update StartDate to StartTimestamp and StopDate to EndTimestamp (#14)
1 parent 09f2eb4 commit 5cafcf4

4 files changed

Lines changed: 76 additions & 74 deletions

File tree

src/aws_durable_execution_sdk_python_testing/executor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ def get_execution_details(self, execution_arn: str) -> GetDurableExecutionRespon
142142
durable_execution_name=execution.start_input.execution_name,
143143
function_arn=f"arn:aws:lambda:us-east-1:123456789012:function:{execution.start_input.function_name}",
144144
status=status,
145-
start_date=execution_op.start_timestamp.isoformat()
145+
start_timestamp=execution_op.start_timestamp.isoformat()
146146
if execution_op.start_timestamp
147147
else datetime.now(UTC).isoformat(),
148148
input_payload=execution_op.execution_details.input_payload
149149
if execution_op.execution_details
150150
else None,
151151
result=result,
152152
error=error,
153-
stop_date=execution_op.end_timestamp.isoformat()
153+
end_timestamp=execution_op.end_timestamp.isoformat()
154154
if execution_op.end_timestamp
155155
else None,
156156
version="1.0",
@@ -223,17 +223,17 @@ def list_executions(
223223
durable_execution_name=execution.start_input.execution_name,
224224
function_arn=f"arn:aws:lambda:us-east-1:123456789012:function:{execution.start_input.function_name}",
225225
status=execution_status,
226-
start_date=execution_op.start_timestamp.isoformat()
226+
start_timestamp=execution_op.start_timestamp.isoformat()
227227
if execution_op.start_timestamp
228228
else datetime.now(UTC).isoformat(),
229-
stop_date=execution_op.end_timestamp.isoformat()
229+
end_timestamp=execution_op.end_timestamp.isoformat()
230230
if execution_op.end_timestamp
231231
else None,
232232
)
233233
filtered_executions.append(execution_summary)
234234

235235
# Sort by start date
236-
filtered_executions.sort(key=lambda e: e.start_date, reverse=reverse_order)
236+
filtered_executions.sort(key=lambda e: e.start_timestamp, reverse=reverse_order)
237237

238238
# Apply pagination
239239
if max_items is None:

src/aws_durable_execution_sdk_python_testing/model.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ class GetDurableExecutionResponse:
131131
durable_execution_name: str
132132
function_arn: str
133133
status: str
134-
start_date: str
134+
start_timestamp: str
135135
input_payload: str | None = None
136136
result: str | None = None
137137
error: ErrorObject | None = None
138-
stop_date: str | None = None
138+
end_timestamp: str | None = None
139139
version: str | None = None
140140

141141
@classmethod
@@ -149,11 +149,11 @@ def from_dict(cls, data: dict) -> GetDurableExecutionResponse:
149149
durable_execution_name=data["DurableExecutionName"],
150150
function_arn=data["FunctionArn"],
151151
status=data["Status"],
152-
start_date=data["StartDate"],
152+
start_timestamp=data["StartTimestamp"],
153153
input_payload=data.get("InputPayload"),
154154
result=data.get("Result"),
155155
error=error,
156-
stop_date=data.get("StopDate"),
156+
end_timestamp=data.get("EndTimestamp"),
157157
version=data.get("Version"),
158158
)
159159

@@ -163,16 +163,18 @@ def to_dict(self) -> dict[str, Any]:
163163
"DurableExecutionName": self.durable_execution_name,
164164
"FunctionArn": self.function_arn,
165165
"Status": self.status,
166-
"StartDate": self.start_date,
166+
"StartTimestamp": self.start_timestamp,
167167
}
168168
if self.input_payload is not None:
169169
result["InputPayload"] = self.input_payload
170170
if self.result is not None:
171171
result["Result"] = self.result
172172
if self.error is not None:
173173
result["Error"] = self.error.to_dict()
174-
if self.stop_date is not None:
175-
result["StopDate"] = self.stop_date
174+
if self.end_timestamp is not None:
175+
result["EndTimestamp"] = self.end_timestamp
176+
if self.end_timestamp is not None:
177+
result["EndTimestamp"] = self.end_timestamp
176178
if self.version is not None:
177179
result["Version"] = self.version
178180
return result
@@ -186,8 +188,8 @@ class Execution:
186188
durable_execution_name: str
187189
function_arn: str
188190
status: str
189-
start_date: str
190-
stop_date: str | None = None
191+
start_timestamp: str
192+
end_timestamp: str | None = None
191193

192194
@classmethod
193195
def from_dict(cls, data: dict) -> Execution:
@@ -198,21 +200,21 @@ def from_dict(cls, data: dict) -> Execution:
198200
"FunctionArn", ""
199201
), # Make optional for backward compatibility
200202
status=data["Status"],
201-
start_date=data["StartDate"],
202-
stop_date=data.get("StopDate"),
203+
start_timestamp=data["StartTimestamp"],
204+
end_timestamp=data.get("EndTimestamp"),
203205
)
204206

205207
def to_dict(self) -> dict[str, Any]:
206208
result = {
207209
"DurableExecutionArn": self.durable_execution_arn,
208210
"DurableExecutionName": self.durable_execution_name,
209211
"Status": self.status,
210-
"StartDate": self.start_date,
212+
"StartTimestamp": self.start_timestamp,
211213
}
212214
if self.function_arn: # Only include if not empty
213215
result["FunctionArn"] = self.function_arn
214-
if self.stop_date is not None:
215-
result["StopDate"] = self.stop_date
216+
if self.end_timestamp is not None:
217+
result["EndTimestamp"] = self.end_timestamp
216218
return result
217219

218220

tests/model_test.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ def test_get_durable_execution_response_serialization():
180180
"DurableExecutionName": "test-execution",
181181
"FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function",
182182
"Status": "SUCCEEDED",
183-
"StartDate": "2023-01-01T00:00:00Z",
183+
"StartTimestamp": "2023-01-01T00:00:00Z",
184184
"InputPayload": "test-input",
185185
"Result": "test-result",
186186
"Error": {"ErrorMessage": "test error"},
187-
"StopDate": "2023-01-01T00:01:00Z",
187+
"EndTimestamp": "2023-01-01T00:01:00Z",
188188
"Version": "1.0",
189189
}
190190

@@ -199,11 +199,11 @@ def test_get_durable_execution_response_serialization():
199199
== "arn:aws:lambda:us-east-1:123456789012:function:my-function"
200200
)
201201
assert response_obj.status == "SUCCEEDED"
202-
assert response_obj.start_date == "2023-01-01T00:00:00Z"
202+
assert response_obj.start_timestamp == "2023-01-01T00:00:00Z"
203203
assert response_obj.input_payload == "test-input"
204204
assert response_obj.result == "test-result"
205205
assert response_obj.error.message == "test error"
206-
assert response_obj.stop_date == "2023-01-01T00:01:00Z"
206+
assert response_obj.end_timestamp == "2023-01-01T00:01:00Z"
207207
assert response_obj.version == "1.0"
208208

209209
result_data = response_obj.to_dict()
@@ -221,14 +221,14 @@ def test_get_durable_execution_response_minimal():
221221
"DurableExecutionName": "test-execution",
222222
"FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function",
223223
"Status": "RUNNING",
224-
"StartDate": "2023-01-01T00:00:00Z",
224+
"StartTimestamp": "2023-01-01T00:00:00Z",
225225
}
226226

227227
response_obj = GetDurableExecutionResponse.from_dict(data)
228228
assert response_obj.input_payload is None
229229
assert response_obj.result is None
230230
assert response_obj.error is None
231-
assert response_obj.stop_date is None
231+
assert response_obj.end_timestamp is None
232232
assert response_obj.version is None
233233

234234
result_data = response_obj.to_dict()
@@ -295,8 +295,8 @@ def test_durable_execution_summary_serialization():
295295
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test",
296296
"DurableExecutionName": "test-execution",
297297
"Status": "SUCCEEDED",
298-
"StartDate": "2023-01-01T00:00:00Z",
299-
"StopDate": "2023-01-01T00:01:00Z",
298+
"StartTimestamp": "2023-01-01T00:00:00Z",
299+
"EndTimestamp": "2023-01-01T00:01:00Z",
300300
}
301301

302302
summary_obj = Execution.from_dict(data)
@@ -306,8 +306,8 @@ def test_durable_execution_summary_serialization():
306306
)
307307
assert summary_obj.durable_execution_name == "test-execution"
308308
assert summary_obj.status == "SUCCEEDED"
309-
assert summary_obj.start_date == "2023-01-01T00:00:00Z"
310-
assert summary_obj.stop_date == "2023-01-01T00:01:00Z"
309+
assert summary_obj.start_timestamp == "2023-01-01T00:00:00Z"
310+
assert summary_obj.end_timestamp == "2023-01-01T00:01:00Z"
311311

312312
result_data = summary_obj.to_dict()
313313
assert result_data == data
@@ -323,11 +323,11 @@ def test_durable_execution_summary_no_stop_date():
323323
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test",
324324
"DurableExecutionName": "test-execution",
325325
"Status": "RUNNING",
326-
"StartDate": "2023-01-01T00:00:00Z",
326+
"StartTimestamp": "2023-01-01T00:00:00Z",
327327
}
328328

329329
summary_obj = Execution.from_dict(data)
330-
assert summary_obj.stop_date is None
330+
assert summary_obj.end_timestamp is None
331331

332332
result_data = summary_obj.to_dict()
333333
assert result_data == data
@@ -341,14 +341,14 @@ def test_list_durable_executions_response_serialization():
341341
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test1",
342342
"DurableExecutionName": "test-execution-1",
343343
"Status": "SUCCEEDED",
344-
"StartDate": "2023-01-01T00:00:00Z",
345-
"StopDate": "2023-01-01T00:01:00Z",
344+
"StartTimestamp": "2023-01-01T00:00:00Z",
345+
"EndTimestamp": "2023-01-01T00:01:00Z",
346346
},
347347
{
348348
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test2",
349349
"DurableExecutionName": "test-execution-2",
350350
"Status": "RUNNING",
351-
"StartDate": "2023-01-01T00:02:00Z",
351+
"StartTimestamp": "2023-01-01T00:02:00Z",
352352
},
353353
],
354354
"NextMarker": "next-marker-123",
@@ -738,8 +738,8 @@ def test_list_durable_executions_by_function_response_serialization():
738738
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test1",
739739
"DurableExecutionName": "test-execution-1",
740740
"Status": "SUCCEEDED",
741-
"StartDate": "2023-01-01T00:00:00Z",
742-
"StopDate": "2023-01-01T00:01:00Z",
741+
"StartTimestamp": "2023-01-01T00:00:00Z",
742+
"EndTimestamp": "2023-01-01T00:01:00Z",
743743
}
744744
],
745745
"NextMarker": "next-marker-123",
@@ -1183,8 +1183,8 @@ def test_execution_backward_compatibility_empty_function_arn():
11831183
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test",
11841184
"DurableExecutionName": "test-execution",
11851185
"Status": "SUCCEEDED",
1186-
"StartDate": "2023-01-01T00:00:00Z",
1187-
"StopDate": "2023-01-01T00:01:00Z",
1186+
"StartTimestamp": "2023-01-01T00:00:00Z",
1187+
"EndTimestamp": "2023-01-01T00:01:00Z",
11881188
}
11891189

11901190
execution_obj = Execution.from_dict(data)
@@ -1198,8 +1198,8 @@ def test_execution_backward_compatibility_empty_function_arn():
11981198
"DurableExecutionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function:execution:test",
11991199
"DurableExecutionName": "test-execution",
12001200
"Status": "SUCCEEDED",
1201-
"StartDate": "2023-01-01T00:00:00Z",
1202-
"StopDate": "2023-01-01T00:01:00Z",
1201+
"StartTimestamp": "2023-01-01T00:00:00Z",
1202+
"EndTimestamp": "2023-01-01T00:01:00Z",
12031203
}
12041204
assert result_data == expected_data
12051205

@@ -1211,8 +1211,8 @@ def test_execution_with_function_arn():
12111211
"DurableExecutionName": "test-execution",
12121212
"FunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:my-function",
12131213
"Status": "SUCCEEDED",
1214-
"StartDate": "2023-01-01T00:00:00Z",
1215-
"StopDate": "2023-01-01T00:01:00Z",
1214+
"StartTimestamp": "2023-01-01T00:00:00Z",
1215+
"EndTimestamp": "2023-01-01T00:01:00Z",
12161216
}
12171217

12181218
execution_obj = Execution.from_dict(data)

0 commit comments

Comments
 (0)