def load_model_from_s3(model_dir, config): try: from rasa_nlu.persistor import Persistor p = Persistor(config['path'], config['aws_region'], config['bucket_name']) p.fetch_and_extract('{0}.tar.gz'.format(os.path.basename(model_dir))) except Exception as e: logging.warn("Using default interpreter, couldn't fetch model: {}".format(e.message))
def create_persistor(config): persistor = None if "bucket_name" in config: from rasa_nlu.persistor import Persistor persistor = Persistor(config.path, config.aws_region, config.bucket_name) return persistor
def __create_interpreter(self): model_dir = self.config.server_model_dir metadata, backend = None, None if model_dir is not None: # download model from S3 if needed if not os.path.isdir(model_dir): try: from rasa_nlu.persistor import Persistor p = Persistor(self.config.path, self.config.aws_region, self.config.bucket_name) p.fetch_and_extract('{0}.tar.gz'.format( os.path.basename(model_dir))) except: warnings.warn( "using default interpreter, couldn't find model dir or fetch it from S3" ) metadata = json.loads( open(os.path.join(model_dir, 'metadata.json'), 'rb').read()) backend = metadata["backend"] if backend is None: from .interpreters.simple_interpreter import HelloGoodbyeInterpreter return HelloGoodbyeInterpreter() elif backend.lower() == 'mitie': logging.info("using mitie backend") from .interpreters.mitie_interpreter import MITIEInterpreter return MITIEInterpreter(**metadata) elif backend.lower() == 'spacy_sklearn': logging.info("using spacy + sklearn backend") from .interpreters.spacy_sklearn_interpreter import SpacySklearnInterpreter return SpacySklearnInterpreter(**metadata) else: raise ValueError("unknown backend : {0}".format(backend))
def create_persistor(config): # type: (RasaNLUConfig) -> Optional[Persistor] """Create a remote persistor to store the model if the configuration requests it.""" persistor = None if "bucket_name" in config: from rasa_nlu.persistor import Persistor persistor = Persistor(config['path'], config['aws_region'], config['bucket_name']) return persistor