From 64621cf21b43b47dcb615a4a626f31b789cac4b0 Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 7 Apr 2017 20:40:31 +0200 Subject: warn and crash on invalid queue jobs --- worker.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'worker.py') diff --git a/worker.py b/worker.py index a1ab696..e53617b 100644 --- a/worker.py +++ b/worker.py @@ -121,8 +121,8 @@ class Model(object): return vars(record.roster[0].match[0])[column] raise KeyError("Invalid path " + path) - def _batch(self, ids=[], size=None): - if len(ids) == 0: # training, get random sample + def _batch(self, ids=None, size=None): + if ids is None: # training, get random sample size = size or self.batchsize # train a model one batch offset = random.random() * self._db.query(Participant).count() @@ -151,6 +151,8 @@ class Model(object): labels = np.array(labels) logging.info("sample size: %s", len(labels)) + if ids is not None: + assert len(ids) == len(labels), "got nonexisting participant" return tf.contrib.learn.io.numpy_input_fn( data, labels, batch_size=self.batchsize, -- cgit v1.3.1