Skip to content

Commit 9c1127f

Browse files
authored
Allow setting of start_timestamp for a resource (#696)
* allow setting of start_timestamp for a resource * only set start_datetime when passed
1 parent 2d0bdf2 commit 9c1127f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/actinia_core/models/response_models.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,22 @@ class ProcessingResponseModel(Schema):
383383
"description": "The current timestamp of the response in human "
384384
"readable format",
385385
},
386+
"start_timestamp": {
387+
"type": "number",
388+
"format": "double",
389+
"description": "The processing start time in seconds of the "
390+
"response",
391+
},
392+
"start_datetime": {
393+
"type": "string",
394+
"description": "The processing start timestamp of the response "
395+
"in human readable format",
396+
},
397+
"process_time_delta": {
398+
"type": "number",
399+
"format": "double",
400+
"description": "The time delta of the processing in seconds",
401+
},
386402
"http_code": {
387403
"type": "number",
388404
"format": "int32",
@@ -1188,6 +1204,8 @@ def create_response_from_model(
11881204
status_url=None,
11891205
orig_time=None,
11901206
orig_datetime=None,
1207+
start_timestamp=None,
1208+
start_datetime=None,
11911209
resource_urls=[],
11921210
api_info=None,
11931211
process_chain_list=[],
@@ -1224,6 +1242,9 @@ def create_response_from_model(
12241242
status_url (str): The url of this request
12251243
orig_time (time): The time of origin (seconds)
12261244
orig_datetime (datetime): The datetime of origin (datetime format)
1245+
start_timestamp (time): The time the processing started (seconds)
1246+
start_datetime (datetime): The datetime the processing started
1247+
(datetime format))
12271248
resource_urls ([str]): The list of url of the new created resources
12281249
api_info (ApiInfoModel): Information about the API call, important for
12291250
accounting
@@ -1282,6 +1303,11 @@ def create_response_from_model(
12821303
resp_dict["api_info"] = api_info
12831304
if iteration is not None:
12841305
resp_dict["iteration"] = iteration
1306+
if start_timestamp is not None:
1307+
resp_dict["start_timestamp"] = start_timestamp
1308+
resp_dict["process_time_delta"] = time.time() - start_timestamp
1309+
if start_datetime is not None:
1310+
resp_dict["start_datetime"] = start_datetime
12851311

12861312
if resp_type == "pickle":
12871313
return pickle.dumps([http_code, resp_dict])

0 commit comments

Comments
 (0)