From 94098c9f595b76ab3d9082b3dd682a6507955603 Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Fri, 16 Nov 2018 08:59:07 +0100 Subject: [PATCH] [algorithm] Improve algorithm process signature check Now both invalid case are treated as exception: - Calling a loop using algorithm without loop_channel - Calling a non loop using alggorithm with a loop_channel --- beat/backend/python/algorithm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/beat/backend/python/algorithm.py b/beat/backend/python/algorithm.py index a322853..af0fc27 100644 --- a/beat/backend/python/algorithm.py +++ b/beat/backend/python/algorithm.py @@ -257,13 +257,16 @@ class Runner(object): elif self.algorithm.type == Algorithm.AUTONOMOUS: run_args = [self.obj, 'process', self.exc, data_loaders, outputs_to_use] - if loop_channel: - sig = signature(self.obj.process) - params = sig.parameters + sig = signature(self.obj.process) + params = sig.parameters + + if loop_channel is not None: if 'loop_channel' in params: run_args.append(loop_channel) else: raise exc("Algorithm '%s' is not a valid loop enabled algorithm" % self.name) + elif 'loop_channel' in params: + raise exc("Algorithm '%s' is a loop enabled algorithm but no loop_channel given" % self.name) return loader.run(*run_args) @@ -287,7 +290,6 @@ class Runner(object): if not self.prepared: raise exc("Algorithm '%s' is not yet prepared" % self.name) - answer = loader.run(self.obj, 'validate', self.exc, result) if not isinstance(answer, tuple): -- GitLab