From 51cd65c30dd93f72625a85f3b352c262cc8b4005 Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 4 Apr 2017 20:45:56 +0200 Subject: send notifications for participant stats --- worker.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/worker.py b/worker.py index f4ee3e5..f8461e9 100644 --- a/worker.py +++ b/worker.py @@ -150,6 +150,8 @@ class Model(object): data[key] = np.array(data[key]) labels = np.array(labels) + logging.info("sample size: %s", len(labels)) + return tf.contrib.learn.io.numpy_input_fn( data, labels, batch_size=self.batchsize, num_epochs=self.steps) @@ -212,8 +214,8 @@ def process(): jobs = queue[:] queue = [] - logging.info("analyzing batch " + str(len(jobs))) - ids = list(set([id for _, _, id in jobs])) + logging.info("analyzing batch %s", str(len(jobs))) + ids = list(set([str(id, "utf-8") for _, _, id in jobs])) ratings = mvpmodel.rate(ids) with db.no_autoflush: @@ -232,6 +234,10 @@ def process(): # ack all until this one logging.info("acking batch") channel.basic_ack(jobs[-1][0].delivery_tag, multiple=True) + # notify web + for api_id in ids: + channel.basic_publish("amq.topic", "participant." + api_id, + "stats_update") logging.basicConfig(level=logging.INFO) -- cgit v1.3.1