def create_component(self, component_name, config): # type: (Text, RasaNLUConfig) -> Component """Tries to retrieve a component from the cache, calls `create` to create a new component.""" from rasa_nlu import registry from rasa_nlu.model import Metadata try: component, cache_key = self.__get_cached_component(component_name, Metadata(config.as_dict(), None)) if component is None: component = registry.create_component_by_name(component_name, config) self.__add_to_cache(component, cache_key) return component except MissingArgumentError as e: # pragma: no cover raise Exception("Failed to create component '{}'. {}".format(component_name, e))
def create_component(self, component_name, config): # type: (Text, RasaNLUConfig) -> Component """Tries to retrieve a component from the cache, calls `create` to create a new component.""" from rasa_nlu import registry from rasa_nlu.model import Metadata try: component, cache_key = self.__get_cached_component(component_name, Metadata(config.as_dict(), None)) if component is None: component = registry.create_component_by_name(component_name, config) self.__add_to_cache(component, cache_key) return component except MissingArgumentError as e: # pragma: no cover raise Exception("Failed to create component '{}'. {}".format(component_name, e))