Пример #1
0
 def make(key, val=None):
     key = to_camel_case(key) if self.__support_snake_case__ else key
     try:
         return self.__configs__[key].from_dict(val) if val else self.__configs__[key]()
     except KeyError:
         raise ValidationError("`{}` is not a valid value for schema `{}`".format(
             key, self.__multi_schema_name__))
Пример #2
0
def get_initializer(module, **kwargs):
    from polyaxon.initializations import INITIALIZERS

    if isinstance(module, six.string_types):
        return INITIALIZERS[to_camel_case(module)](**kwargs)
    if isinstance(module, Mapping):
        config = InitializerSchema(strict=True).load(data=module).data
        return INITIALIZERS[config.IDENTIFIER](**config.to_dict())
    return module