23 lines
826 B
Python
23 lines
826 B
Python
import json, io
|
|
|
|
from services.base import Base
|
|
from helpers import aws_helper
|
|
from models.ability_estimation import AbilityEstimation
|
|
from lib.application_configs import ApplicationConfigs
|
|
|
|
class AbilityEstimationService(Base):
|
|
ACTION = 'abilityEstimation'
|
|
|
|
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())
|
|
|
|
# temp file name
|
|
self.file_name = f'{ability_estimation.exam_id}_ability_estimation_result.json'
|
|
|
|
return aws_helper.file_stream_upload(
|
|
io.BytesIO(bytes(json_data.encode('UTF-8'))), self.file_name,
|
|
ApplicationConfigs.s3_processed_bucket, self.ACTION)
|