diff --git a/beat/backend/python/algorithm.py b/beat/backend/python/algorithm.py index 36d251063080f97de90809711fa54ffe0d7bb486..ca2f7eda87901f63649c7d46d2fde9a87a1c2418 100644 --- a/beat/backend/python/algorithm.py +++ b/beat/backend/python/algorithm.py @@ -271,6 +271,25 @@ class Runner(object): raise exc('Unknown algorithm type: %s' % self.algorithm.type) + def validate(self, result): + """Validates the given results""" + + exc = self.exc or RuntimeError + + if self.algorithm.type != Algorithm.LOOP: + raise exc('Wrong algorithm type: %s' % self.algorithm.type) + + # setup() must have run + if not self.ready: + raise exc("Algorithm '%s' is not yet setup" % self.name) + + # prepare() must have run + if not self.prepared: + raise exc("Algorithm '%s' is not yet prepared" % self.name) + + return loader.run(self.obj, 'validate', self.exc, result) + + def __getattr__(self, key): """Returns an attribute of the algorithm - only called at last resort """