def test_endpoint_config(): endpoint = EndpointConfig("https://abc.defg/", params={"A": "B"}, headers={"X-Powered-By": "Rasa"}, basic_auth={ "username": "******", "password": "******" }, token="mytoken", token_name="letoken") httpretty.register_uri(httpretty.POST, 'https://abc.defg/test', status=500, body='') httpretty.enable() endpoint.request("post", subpath="test", content_type="application/text", json={"c": "d"}, params={"P": "1"}) httpretty.disable() r = httpretty.latest_requests[-1] assert json.loads(str(r.body.decode("utf-8"))) == {"c": "d"} assert r.headers.get("X-Powered-By") == "Rasa" assert r.headers.get("Authorization") == "Basic dXNlcjpwYXNz" assert r.querystring.get("A") == ["B"] assert r.querystring.get("P") == ["1"] assert r.querystring.get("letoken") == ["mytoken"]
def test_project_with_model_server(zipped_nlu_model): fingerprint = 'somehash' model_endpoint = EndpointConfig('http://server.com/models/nlu/tags/latest') # mock a response that returns a zipped model with io.open(zipped_nlu_model, 'rb') as f: responses.add(responses.GET, model_endpoint.url, headers={ "ETag": fingerprint, "filename": "my_model_xyz.zip" }, body=f.read(), content_type='application/zip', stream=True) project = load_from_server(model_server=model_endpoint) assert project.fingerprint == fingerprint
interpreter = trainer.train(training_data, **kwargs) if path: persisted_path = trainer.persist(path, persistor, project, fixed_model_name) else: persisted_path = None return trainer, interpreter, persisted_path if __name__ == '__main__': cmdline_args = create_argument_parser().parse_args() utils.configure_colored_logging(cmdline_args.loglevel) if cmdline_args.url: data_endpoint = EndpointConfig(cmdline_args.url) else: data_endpoint = read_endpoints(cmdline_args.endpoints).data do_train(config.load(cmdline_args.config), cmdline_args.data, cmdline_args.path, cmdline_args.project, cmdline_args.fixed_model_name, cmdline_args.storage, data_endpoint=data_endpoint, num_threads=cmdline_args.num_threads) logger.info("Finished training")