diff --git a/analytics/analytic_unit_worker.py b/analytics/analytic_unit_worker.py index f586b9b..5fd665c 100644 --- a/analytics/analytic_unit_worker.py +++ b/analytics/analytic_unit_worker.py @@ -28,7 +28,7 @@ class AnalyticUnitWorker(object): result = await self.do_learn(analytic_unit_id, segments, pattern) else: result = { - 'status': "failed", + 'status': "FAILED", 'error': "unknown type " + str(type) } except Exception as e: @@ -50,7 +50,7 @@ class AnalyticUnitWorker(object): last_prediction_time = await model.learn(segments) # TODO: we should not do predict before labeling in all models, not just in drops - if pattern == 'drop' and len(segments) == 0: + if pattern == 'DROP' and len(segments) == 0: # TODO: move result to a class which renders to json for messaging to analytics result = { 'status': 'SUCCESS', @@ -61,7 +61,7 @@ class AnalyticUnitWorker(object): else: result = await self.do_predict(analytic_unit_id, last_prediction_time, pattern) - result['task'] = 'learn' + result['task'] = 'LEARN' return result async def do_predict(self, analytic_unit_id, last_prediction_time, pattern): diff --git a/analytics/server.py b/analytics/server.py index 07e5d00..7548bcc 100644 --- a/analytics/server.py +++ b/analytics/server.py @@ -46,7 +46,8 @@ async def handle_task(task: object): res = await worker.do_task(task) res['_taskId'] = task['_taskId'] - await server_service.send_message(json.dumps(res)) + message = services.server_service.ServerMessage('TASK_RESULT', res) + await server_service.send_message(message) except Exception as e: logger.error("handle_task Exception: '%s'" % str(e))