def app(component_builder): """ This fixture makes use of the IResource interface of the Klein application to mock Rasa HTTP server. :param component_builder: :return: """ if "TRAVIS_BUILD_DIR" in os.environ: root_dir = os.environ["TRAVIS_BUILD_DIR"] else: root_dir = os.getcwd() _, nlu_log_file = tempfile.mkstemp(suffix="_rasa_nlu_logs.json") _config = { 'write': nlu_log_file, 'port': -1, # unused in test app "pipeline": "keyword", "path": os.path.join(root_dir, "test_projects"), "data": os.path.join(root_dir, "data/demo-restaurants.json"), "max_training_processes": 1 } train_models(component_builder) config = RasaNLUConfig(cmdline_args=_config) rasa = RasaNLU(config, component_builder, True) return StubTreq(rasa.app.resource())
def app(tmpdir_factory): """Use IResource interface of Klein to mock Rasa HTTP server. :param component_builder: :return: """ _, nlu_log_file = tempfile.mkstemp(suffix="_rasa_nlu_logs.json") router = DataRouter(tmpdir_factory.mktemp("projects").strpath) rasa = RasaNLU(router, logfile=nlu_log_file, testing=True) return StubTreq(rasa.app.resource())
def app(component_builder): """Use IResource interface of Klein to mock Rasa HTTP server. :param component_builder: :return: """ if "TRAVIS_BUILD_DIR" in os.environ: root_dir = os.environ["TRAVIS_BUILD_DIR"] else: root_dir = os.getcwd() _, nlu_log_file = tempfile.mkstemp(suffix="_rasa_nlu_logs.json") train_models(component_builder, os.path.join(root_dir, "data/examples/rasa/demo-rasa.json")) router = DataRouter(os.path.join(root_dir, "test_projects")) rasa = RasaNLU(router, logfile=nlu_log_file, testing=True) return StubTreq(rasa.app.resource())
def app(tmpdir_factory): """ This fixture makes use of the IResource interface of the Klein application to mock Rasa HTTP server. :param component_builder: :return: """ _, nlu_log_file = tempfile.mkstemp(suffix="_rasa_nlu_logs.json") _config = { 'write': nlu_log_file, 'port': -1, # unused in test app "pipeline": "keyword", "path": tmpdir_factory.mktemp("projects").strpath, "server_model_dirs": {}, "data": "./data/demo-restaurants.json", "emulate": "wit", "max_training_processes": 1 } config = RasaNLUConfig(cmdline_args=_config) rasa = RasaNLU(config, testing=True) return StubTreq(rasa.app.resource())