upload estimation to s3
This commit is contained in:
parent
7a14856775
commit
504d58dca0
@ -1,5 +1,9 @@
|
||||
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'
|
||||
@ -7,6 +11,12 @@ class AbilityEstimationService(Base):
|
||||
def process(self):
|
||||
attributes = self.service_attributes()
|
||||
ability_estimation = AbilityEstimation.parse_obj(attributes)
|
||||
results = ability_estimation.calculate()
|
||||
# we need to convert the results from numpy array to a list to dump to json
|
||||
json_data = json.dumps(ability_estimation.calculate().tolist())
|
||||
|
||||
return None
|
||||
# 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)
|
||||
|
@ -23,3 +23,5 @@ class Base:
|
||||
attributes = json.loads(
|
||||
tar_helper.extract_file_from_tar(
|
||||
self.tar, f'{action_snake}_attributes.json').read())
|
||||
|
||||
return attributes
|
||||
|
Loading…
x
Reference in New Issue
Block a user