better abstraction and error handling/logging
This commit is contained in:
@ -11,12 +11,21 @@ class AbilityEstimationService(Base):
|
||||
def process(self):
|
||||
attributes = self.service_attributes()
|
||||
ability_estimation = AbilityEstimation.parse_obj(attributes)
|
||||
# we need to convert the results from numpy array to a list to dump to json
|
||||
json_data = json.dumps(ability_estimation.calculate().tolist())
|
||||
result = ability_estimation.calculate()
|
||||
|
||||
# temp file name
|
||||
self.file_name = f'{ability_estimation.exam_id}_ability_estimation_result.json'
|
||||
if result is not None:
|
||||
response = json.dumps({
|
||||
'status': 'success',
|
||||
'result': result
|
||||
})
|
||||
|
||||
self.file_name = f'{ability_estimation.exam_id}_ability_estimation_result.json'
|
||||
else:
|
||||
response = json.dumps({
|
||||
'status': 'error',
|
||||
'result': None
|
||||
})
|
||||
|
||||
return aws_helper.file_stream_upload(
|
||||
io.BytesIO(bytes(json_data.encode('UTF-8'))), self.file_name,
|
||||
io.BytesIO(bytes(response.encode('UTF-8'))), self.file_name,
|
||||
ApplicationConfigs.s3_processed_bucket, self.ACTION)
|
||||
|
Reference in New Issue
Block a user