added 0.3.2
This commit is contained in:
@ -1,7 +1,4 @@
|
||||
import os
|
||||
import json
|
||||
import random
|
||||
import io
|
||||
import os, json, random, io, logging
|
||||
|
||||
from helpers import aws_helper, tar_helper, csv_helper, service_helper, irt_helper
|
||||
|
||||
@ -18,6 +15,7 @@ class LoftService(Base):
|
||||
self.result = self.stream_to_s3_bucket()
|
||||
|
||||
def retreive_attributes_from_message(self):
|
||||
logging.info('Retrieving attributes from message...')
|
||||
# get s3 object
|
||||
self.key = aws_helper.get_key_from_message(self.source)
|
||||
s3_object = aws_helper.get_object(self.key, os.environ['SOLVER_INGEST_BUCKET'])
|
||||
@ -34,10 +32,12 @@ class LoftService(Base):
|
||||
|
||||
# add items to attributes dict
|
||||
attributes['items'] = service_helper.items_csv_to_dict(items_csv_reader)
|
||||
logging.info('Processed Attributes...')
|
||||
|
||||
return attributes
|
||||
|
||||
def generate_solution(self):
|
||||
logging.info('Processing Solution...')
|
||||
# temporary data for mocks
|
||||
form_count = 10
|
||||
|
||||
@ -49,9 +49,11 @@ class LoftService(Base):
|
||||
)
|
||||
|
||||
def stream_to_s3_bucket(self):
|
||||
self.file_name = f'{service_helper.key_to_uuid(self.key)}.csv'
|
||||
logging.info('Streaming to %s s3 bucket %s', self.file_name, os.environ['MEASURE_PROCESSED_BUCKET'])
|
||||
# setup writer buffer and write processed forms to file
|
||||
buffer = io.StringIO()
|
||||
solution_file = service_helper.solution_to_file(buffer, self.solver_run.total_form_items, self.solution.forms)
|
||||
|
||||
# upload generated file to s3 and return result
|
||||
return aws_helper.file_stream_upload(solution_file, f'{service_helper.key_to_uuid(self.key)}.csv', os.environ['MEASURE_PROCESSED_BUCKET'])
|
||||
return aws_helper.file_stream_upload(solution_file, self.file_name, os.environ['MEASURE_PROCESSED_BUCKET'])
|
||||
|
Reference in New Issue
Block a user