def validate(cls, settings): """Validate the settings against the schema""" res = schemas.validate(cls.SCHEMA, settings) features = flatten_features(settings.get('features')) res['features'] = features has_input = False has_output = False for feature in res['features']: io = feature.get('io', 'io') if 'i' in io: has_input = True if 'o' in io: has_output = True if has_input and has_output: break if not has_input: raise errors.Invalid('model has no input feature') if not has_output: raise errors.Invalid('model has no output feature') return res
def valid(self, value): schemas.validate(self.schema, value)
def invalid(self, value): with self.assertRaises(errors.Invalid): schemas.validate(self.schema, value)
def validate(cls, cfg): """Validate configuration against the schema""" return schemas.validate(cls.SCHEMA, cfg)
def validate(cls, settings): """Validate the settings against the schema""" return schemas.validate(cls.SCHEMA, settings)
def validate(cls, args): del args['self'] return schemas.validate(cls.SCHEMA, args)