How to use the omegaml.util.load_class function in omegaml

To help you get started, we’ve selected a few omegaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github omegaml / omegaml / omegaml / store / base.py View on Github external
def get_backend_bykind(self, kind, model_store=None, data_store=None,
                           **kwargs):
        """
        return the backend by a given object kind

        :param kind: The object kind
        :param model_store: the OmegaStore instance used to store models
        :param data_store: the OmegaStore instance used to store data
        :param kwargs: the kwargs passed to the backend initialization
        :return: the backend 
        """
        try:
            backend_cls = load_class(self.defaults.OMEGA_STORE_BACKENDS[kind])
        except:
            raise ValueError('backend {kind} does not exist'.forma(**locals()))
        model_store = model_store or self
        data_store = data_store or self
        backend = backend_cls(model_store=model_store,
                              data_store=data_store, **kwargs)
        return backend
github omegaml / omegaml / omegaml / store / base.py View on Github external
def register_backend(self, kind, backend):
        """
        register a backend class

        :param kind: (str) the backend kind
        :param backend: (class) the backend class 
        """
        self.defaults.OMEGA_STORE_BACKENDS[kind] = load_class(backend)
        if kind not in MDREGISTRY.KINDS:
            MDREGISTRY.KINDS.append(kind)
        return self