Skip to content
Snippets Groups Projects
Commit 94098c9f authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[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
parent cfc3cad6
Branches
Tags
2 merge requests!281.6.x,!27Soft loop
...@@ -257,13 +257,16 @@ class Runner(object): ...@@ -257,13 +257,16 @@ class Runner(object):
elif self.algorithm.type == Algorithm.AUTONOMOUS: elif self.algorithm.type == Algorithm.AUTONOMOUS:
run_args = [self.obj, 'process', self.exc, data_loaders, outputs_to_use] run_args = [self.obj, 'process', self.exc, data_loaders, outputs_to_use]
if loop_channel: sig = signature(self.obj.process)
sig = signature(self.obj.process) params = sig.parameters
params = sig.parameters
if loop_channel is not None:
if 'loop_channel' in params: if 'loop_channel' in params:
run_args.append(loop_channel) run_args.append(loop_channel)
else: else:
raise exc("Algorithm '%s' is not a valid loop enabled algorithm" % self.name) 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) return loader.run(*run_args)
...@@ -287,7 +290,6 @@ class Runner(object): ...@@ -287,7 +290,6 @@ class Runner(object):
if not self.prepared: if not self.prepared:
raise exc("Algorithm '%s' is not yet prepared" % self.name) raise exc("Algorithm '%s' is not yet prepared" % self.name)
answer = loader.run(self.obj, 'validate', self.exc, result) answer = loader.run(self.obj, 'validate', self.exc, result)
if not isinstance(answer, tuple): if not isinstance(answer, tuple):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment