in decisionai_plugin/common/tsanaclient.py [0:0]
def save_inference_result(self, parameters, result, batch_size=1000):
try:
if len(result) <= 0:
return STATUS_SUCCESS, ''
for batch_index in range(math.ceil(len(result) / batch_size)):
body = {
'groupId': parameters['groupId'],
'instanceId': parameters['instance']['instanceId'],
'results': []
}
batch_start = batch_index * batch_size
for step in range(min(batch_size, len(result) - batch_start)):
item = result[batch_start + step]
item['timestamp'] = dt_to_str(str_to_dt(item['timestamp']))
body['results'].append({
'params': parameters['instance']['params'],
'timestamp': item['timestamp'],
'result': item['value'],
'status': item['status']
})
self.post(TSG_ENDPOINT if IS_INTERNAL else parameters['apiEndpointV2'] + TSG_API, parameters[INSTANCE_ID_KEY], parameters['apiKey'], parameters['groupId'] + USER_ADDR, '/timeSeriesGroups/' + parameters['groupId'] + '/appInstances/' + parameters['instance']['instanceId'] + '/saveResult', body)
return STATUS_SUCCESS, ''
except Exception as e:
return STATUS_FAIL, str(e)