added methodology for delegating to service, fixed some formatting, cleaned up dangling imports
This commit is contained in:
parent
8f182ef170
commit
7e68606cc1
@ -20,11 +20,9 @@ else:
|
|||||||
def get_key_from_message(body: dict) -> str:
|
def get_key_from_message(body: dict) -> str:
|
||||||
return body['Records'][0]['s3']['object']['key']
|
return body['Records'][0]['s3']['object']['key']
|
||||||
|
|
||||||
|
|
||||||
def get_bucket_from_message(body: dict) -> str:
|
def get_bucket_from_message(body: dict) -> str:
|
||||||
return body['Records'][0]['s3']['bucket']['name']
|
return body['Records'][0]['s3']['bucket']['name']
|
||||||
|
|
||||||
|
|
||||||
def get_object(key: str, bucket: str) -> bytes:
|
def get_object(key: str, bucket: str) -> bytes:
|
||||||
return s3.get_object(
|
return s3.get_object(
|
||||||
Bucket=bucket,
|
Bucket=bucket,
|
||||||
|
16
app/main.py
16
app/main.py
@ -23,7 +23,21 @@ class ServiceListener(Consumer):
|
|||||||
# but depending on if we can add the tagset to the sqs message body
|
# but depending on if we can add the tagset to the sqs message body
|
||||||
# we either extract that and then delegate to the appropriate service
|
# we either extract that and then delegate to the appropriate service
|
||||||
# or get the action tag from the object through the aws helper function
|
# or get the action tag from the object through the aws helper function
|
||||||
service = FormGenerationService(body)
|
service = None
|
||||||
|
key = aws_helper.get_key_from_message(body)
|
||||||
|
bucket = aws_helper.get_bucket_from_message(body)
|
||||||
|
action = aws_helper.get_object_tag(key, bucket, 'action')['Value']
|
||||||
|
|
||||||
|
logging.info(f'Process starting for {action}')
|
||||||
|
|
||||||
|
if action == 'formGeneration':
|
||||||
|
service = FormGenerationService(body)
|
||||||
|
elif action == 'abilityEstimation':
|
||||||
|
service = AbilityEstimationService(body)
|
||||||
|
else:
|
||||||
|
logging.error(f'action of type {action} does not exist.')
|
||||||
|
return
|
||||||
|
|
||||||
service.process()
|
service.process()
|
||||||
|
|
||||||
logging.info('Process complete for %s', service.file_name)
|
logging.info('Process complete for %s', service.file_name)
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from services.base import Base
|
from services.base import Base
|
||||||
|
|
||||||
class AbilityEstimationService(Base):
|
class AbilityEstimationService(Base):
|
||||||
pass
|
|
||||||
|
def process(self):
|
||||||
|
logging.info('Ability Estimation Service to be implemented...')
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import os, json, random, io, logging
|
import json, random, io, logging
|
||||||
|
|
||||||
from pulp import LpProblem, LpVariable, LpMinimize, LpMaximize, LpAffineExpression, LpConstraint, LpStatus, lpSum
|
from pulp import LpProblem, LpVariable, LpMinimize, LpMaximize, LpAffineExpression, LpConstraint, LpStatus, lpSum
|
||||||
|
|
||||||
@ -9,7 +9,6 @@ from lib.errors.item_generation_error import ItemGenerationError
|
|||||||
from models.solver_run import SolverRun
|
from models.solver_run import SolverRun
|
||||||
from models.solution import Solution
|
from models.solution import Solution
|
||||||
from models.form import Form
|
from models.form import Form
|
||||||
from models.item import Item
|
|
||||||
from models.target import Target
|
from models.target import Target
|
||||||
|
|
||||||
from services.base import Base
|
from services.base import Base
|
||||||
|
Loading…
x
Reference in New Issue
Block a user