From 3e8e65dd5c75a10feb6b96b8c05d3221315b9066 Mon Sep 17 00:00:00 2001 From: Philip ABBET <philip.abbet@idiap.ch> Date: Wed, 20 Sep 2017 16:43:38 +0200 Subject: [PATCH] [executor] Add more checks to ensure the JSON configuration is valid --- beat/core/execution/base.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/beat/core/execution/base.py b/beat/core/execution/base.py index 14f3dfbe..a8610f5b 100755 --- a/beat/core/execution/base.py +++ b/beat/core/execution/base.py @@ -183,6 +183,24 @@ class BaseExecutor(object): self.errors += self.algorithm.errors return + # Check that the mapping in coherent + if len(self.data['inputs']) != len(self.algorithm.input_map): + self.errors.append("The number of inputs of the algorithm doesn't correspond") + + if len(self.data['outputs']) != len(self.algorithm.output_map): + self.errors.append("The number of outputs of the algorithm doesn't correspond") + + for name in self.data['inputs'].keys(): + if name not in self.algorithm.input_map.keys(): + self.errors.append("The input '%s' doesn't exist in the algorithm" % name) + + for name in self.data['outputs'].keys(): + if name not in self.algorithm.output_map.keys(): + self.errors.append("The output '%s' doesn't exist in the algorithm" % name) + + if self.errors: + return + # Load the databases (if any is required) for name, details in self.data['inputs'].items(): if 'database' in details: -- GitLab