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

[algorithm] Refactor process method for loop channel parameter

This allows to have a different process method signature
for algorithm using a loop block and no need to modify
existing algorithms.
parent 8ffdb288
No related branches found
No related tags found
2 merge requests!281.6.x,!27Soft loop
......@@ -42,6 +42,8 @@ import six
import numpy
import simplejson
from inspect import signature
from . import dataformat
from . import library
from . import loader
......@@ -214,7 +216,7 @@ class Runner(object):
return self.prepared
def process(self, inputs=None, data_loaders=None, outputs=None, output=None):
def process(self, inputs=None, data_loaders=None, outputs=None, output=None, loop_channel=None):
"""Runs through data"""
exc = self.exc or RuntimeError
......@@ -248,12 +250,22 @@ class Runner(object):
if self.algorithm.type == Algorithm.SEQUENTIAL:
_check_argument(inputs, 'inputs')
return loader.run(self.obj, 'process', self.exc, inputs, data_loaders,
outputs_to_use)
elif self.algorithm.type == Algorithm.AUTONOMOUS:
return loader.run(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)
params = sig.parameters
if 'loop_channel' in params:
run_args.append(loop_channel)
else:
raise exc("Algorithm '%s' is not a valid loop enabled algorithm" % self.name)
return loader.run(*run_args)
else:
raise exc('Unknown algorithm type: %s' % self.algorithm.type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment