Пример #1
0
    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
Пример #2
0
 def valid(self, value):
     schemas.validate(self.schema, value)
Пример #3
0
 def invalid(self, value):
     with self.assertRaises(errors.Invalid):
         schemas.validate(self.schema, value)
Пример #4
0
 def validate(cls, cfg):
     """Validate configuration against the schema"""
     return schemas.validate(cls.SCHEMA, cfg)
Пример #5
0
 def validate(cls, settings):
     """Validate the settings against the schema"""
     return schemas.validate(cls.SCHEMA, settings)
Пример #6
0
 def validate(cls, args):
     del args['self']
     return schemas.validate(cls.SCHEMA, args)