From 93083c24b3231aa3b581f8bfa9685970ba88edf8 Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@idiap.ch>
Date: Fri, 26 Oct 2018 16:40:48 +0200
Subject: [PATCH] [algorithm][Runner] Implement validate method

This will call the validation method of the loop algorithm.
---
 beat/backend/python/algorithm.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/beat/backend/python/algorithm.py b/beat/backend/python/algorithm.py
index 36d2510..ca2f7ed 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
         """
-- 
GitLab