From c2f6f197774fbe914f255ccf5e2f1b44f4d37275 Mon Sep 17 00:00:00 2001 From: mmalhotra Date: Mon, 2 Mar 2020 16:59:39 -0500 Subject: [PATCH 01/24] Make Rasa server response timeout configurable --- changelog/4756.improvement.rst | 2 ++ rasa/cli/arguments/run.py | 6 ++++++ rasa/constants.py | 1 + rasa/core/constants.py | 2 ++ rasa/core/run.py | 4 ++++ rasa/server.py | 4 +++- tests/cli/test_rasa_run.py | 4 ++-- tests/cli/test_rasa_shell.py | 1 + tests/cli/test_rasa_x.py | 1 + 9 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 changelog/4756.improvement.rst diff --git a/changelog/4756.improvement.rst b/changelog/4756.improvement.rst new file mode 100644 index 000000000000..f9ed9d1bf531 --- /dev/null +++ b/changelog/4756.improvement.rst @@ -0,0 +1,2 @@ +Make Rasa server response timeout configurable. +Rasa server can now be started with `--response-timeout ` to configure a response timeout of seconds. diff --git a/rasa/cli/arguments/run.py b/rasa/cli/arguments/run.py index cd4787eaa313..d424be7075bd 100644 --- a/rasa/cli/arguments/run.py +++ b/rasa/cli/arguments/run.py @@ -56,6 +56,12 @@ def add_server_arguments(parser: argparse.ArgumentParser): action="store_true", help="Start the web server API in addition to the input channel.", ) + server_arguments.add_argument( + "--response-timeout", + default=constants.DEFAULT_RESPONSE_TIMEOUT, + type=int, + help="Maximum time a response can take to process (sec).", + ) server_arguments.add_argument( "--remote-storage", help="Set the remote location where your Rasa model is stored, e.g. on AWS.", diff --git a/rasa/constants.py b/rasa/constants.py index 2c4c61fd6394..224d2917e372 100644 --- a/rasa/constants.py +++ b/rasa/constants.py @@ -11,6 +11,7 @@ DEFAULT_NLU_RESULTS_PATH = "nlu_comparison_results" DEFAULT_CORE_SUBDIRECTORY_NAME = "core" DEFAULT_REQUEST_TIMEOUT = 60 * 5 # 5 minutes +DEFAULT_RESPONSE_TIMEOUT = 60 * 60 # 1 hour TEST_DATA_FILE = "test.md" TRAIN_DATA_FILE = "train.md" diff --git a/rasa/core/constants.py b/rasa/core/constants.py index b4d45ecca515..83e809d60601 100644 --- a/rasa/core/constants.py +++ b/rasa/core/constants.py @@ -12,6 +12,8 @@ DEFAULT_REQUEST_TIMEOUT = 60 * 5 # 5 minutes +DEFAULT_RESPONSE_TIMEOUT = 60 * 60 # 1 hour + DEFAULT_LOCK_LIFETIME = 60 # in seconds REQUESTED_SLOT = "requested_slot" diff --git a/rasa/core/run.py b/rasa/core/run.py index 6ec641838ce2..e105caf55dc5 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -82,6 +82,7 @@ def configure_app( cors: Optional[Union[Text, List[Text], None]] = None, auth_token: Optional[Text] = None, enable_api: bool = True, + response_timeout: int = constants.DEFAULT_RESPONSE_TIMEOUT, jwt_secret: Optional[Text] = None, jwt_method: Optional[Text] = None, route: Optional[Text] = "/webhooks/", @@ -99,6 +100,7 @@ def configure_app( app = server.create_app( cors_origins=cors, auth_token=auth_token, + response_timeout=response_timeout, jwt_secret=jwt_secret, jwt_method=jwt_method, endpoints=endpoints, @@ -148,6 +150,7 @@ def serve_application( cors: Optional[Union[Text, List[Text]]] = None, auth_token: Optional[Text] = None, enable_api: bool = True, + response_timeout: int = constants.DEFAULT_RESPONSE_TIMEOUT, jwt_secret: Optional[Text] = None, jwt_method: Optional[Text] = None, endpoints: Optional[AvailableEndpoints] = None, @@ -171,6 +174,7 @@ def serve_application( cors, auth_token, enable_api, + response_timeout, jwt_secret, jwt_method, port=port, diff --git a/rasa/server.py b/rasa/server.py index ad1f8dbfd00e..a31bdbf7c301 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -19,6 +19,7 @@ from rasa.constants import ( DEFAULT_DOMAIN_PATH, DEFAULT_MODELS_PATH, + DEFAULT_RESPONSE_TIMEOUT, DOCS_BASE_URL, MINIMUM_COMPATIBLE_VERSION, ) @@ -372,6 +373,7 @@ def create_app( agent: Optional["Agent"] = None, cors_origins: Union[Text, List[Text], None] = "*", auth_token: Optional[Text] = None, + response_timeout: int = DEFAULT_RESPONSE_TIMEOUT, jwt_secret: Optional[Text] = None, jwt_method: Text = "HS256", endpoints: Optional[AvailableEndpoints] = None, @@ -379,7 +381,7 @@ def create_app( """Class representing a Rasa HTTP server.""" app = Sanic(__name__) - app.config.RESPONSE_TIMEOUT = 60 * 60 + app.config.RESPONSE_TIMEOUT = response_timeout configure_cors(app, cors_origins) # Setup the Sanic-JWT extension diff --git a/tests/cli/test_rasa_run.py b/tests/cli/test_rasa_run.py index 7a054b26619a..b35d49d7c343 100644 --- a/tests/cli/test_rasa_run.py +++ b/tests/cli/test_rasa_run.py @@ -19,8 +19,8 @@ def test_run_help(run: Callable[..., RunResult]): output = run("run", "--help") help_text = """usage: rasa run [-h] [-v] [-vv] [--quiet] [-m MODEL] [--log-file LOG_FILE] - [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN] - [--cors [CORS [CORS ...]]] [--enable-api] + [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN] + [--response-timeout RESPONSE_TIMEOUT] [--cors [CORS [CORS ...]]] [--enable-api] [--remote-storage REMOTE_STORAGE] [--ssl-certificate SSL_CERTIFICATE] [--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE] diff --git a/tests/cli/test_rasa_shell.py b/tests/cli/test_rasa_shell.py index 6f156ba1ba3a..f6c2d5d5c457 100644 --- a/tests/cli/test_rasa_shell.py +++ b/tests/cli/test_rasa_shell.py @@ -8,6 +8,7 @@ def test_shell_help(run: Callable[..., RunResult]): help_text = """usage: rasa shell [-h] [-v] [-vv] [--quiet] [--conversation-id CONVERSATION_ID] [-m MODEL] [--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT] + [--response-timeout RESPONSE_TIMEOUT] [-t AUTH_TOKEN] [--cors [CORS [CORS ...]]] [--enable-api] [--remote-storage REMOTE_STORAGE] [--ssl-certificate SSL_CERTIFICATE] diff --git a/tests/cli/test_rasa_x.py b/tests/cli/test_rasa_x.py index 656ec082b8a4..852994b50d28 100644 --- a/tests/cli/test_rasa_x.py +++ b/tests/cli/test_rasa_x.py @@ -20,6 +20,7 @@ def test_x_help(run: Callable[..., RunResult]): [--no-prompt] [--production] [--rasa-x-port RASA_X_PORT] [--config-endpoint CONFIG_ENDPOINT] [--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN] + [--response-timeout RESPONSE_TIMEOUT] [--cors [CORS [CORS ...]]] [--enable-api] [--remote-storage REMOTE_STORAGE] [--ssl-certificate SSL_CERTIFICATE] [--ssl-keyfile SSL_KEYFILE] From ac455b08d5c2a3491fdd4072d97a5b959d0bb3a7 Mon Sep 17 00:00:00 2001 From: mmalhotra Date: Mon, 2 Mar 2020 17:16:48 -0500 Subject: [PATCH 02/24] fix flak8 issues --- docs/conf.py | 8 ++++---- tests/cli/test_rasa_run.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 7c6816575d5e..04dbbfd2f39e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -236,13 +236,13 @@ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). - #'papersize': 'letterpaper', + # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). - #'pointsize': '10pt', + # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. - #'preamble': '', + # 'preamble': '', # Latex figure (float) alignment - #'figure_align': 'htbp', + # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples diff --git a/tests/cli/test_rasa_run.py b/tests/cli/test_rasa_run.py index b35d49d7c343..9975ad4bf677 100644 --- a/tests/cli/test_rasa_run.py +++ b/tests/cli/test_rasa_run.py @@ -19,7 +19,7 @@ def test_run_help(run: Callable[..., RunResult]): output = run("run", "--help") help_text = """usage: rasa run [-h] [-v] [-vv] [--quiet] [-m MODEL] [--log-file LOG_FILE] - [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN] + [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN] [--response-timeout RESPONSE_TIMEOUT] [--cors [CORS [CORS ...]]] [--enable-api] [--remote-storage REMOTE_STORAGE] [--ssl-certificate SSL_CERTIFICATE] From ae4231daca442da6309893dfa4ee22f6c82865ae Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Mon, 16 Mar 2020 13:22:01 -0400 Subject: [PATCH 03/24] Update changelog/4756.improvement.rst Co-Authored-By: ricwo --- changelog/4756.improvement.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog/4756.improvement.rst b/changelog/4756.improvement.rst index f9ed9d1bf531..f506a2c9c6ae 100644 --- a/changelog/4756.improvement.rst +++ b/changelog/4756.improvement.rst @@ -1,2 +1,3 @@ Make Rasa server response timeout configurable. -Rasa server can now be started with `--response-timeout ` to configure a response timeout of seconds. +Rasa server can now be started with ``--response-timeout `` to configure a +response timeout of ```` seconds. From 4c9b3c655eec6e6d57d35ef8a239a2ffc3304d78 Mon Sep 17 00:00:00 2001 From: mmalhotra Date: Mon, 16 Mar 2020 13:49:36 -0400 Subject: [PATCH 04/24] fix deepsource issues --- rasa/cli/arguments/run.py | 6 ++++++ rasa/core/constants.py | 3 ++- rasa/core/run.py | 2 ++ rasa/server.py | 18 ++++++++++++++---- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/rasa/cli/arguments/run.py b/rasa/cli/arguments/run.py index d424be7075bd..6c1f7fe5b029 100644 --- a/rasa/cli/arguments/run.py +++ b/rasa/cli/arguments/run.py @@ -5,17 +5,23 @@ def set_run_arguments(parser: argparse.ArgumentParser): + """Arguments for running rasa directly.""" + add_model_param(parser) add_server_arguments(parser) def set_run_action_arguments(parser: argparse.ArgumentParser): + """Set arguments for running action sdk.""" + import rasa_sdk.cli.arguments as sdk sdk.add_endpoint_arguments(parser) def add_server_arguments(parser: argparse.ArgumentParser): + """Add arguments for running API endpoint.""" + parser.add_argument( "--log-file", type=str, diff --git a/rasa/core/constants.py b/rasa/core/constants.py index 83e809d60601..ff9bf2741e4a 100644 --- a/rasa/core/constants.py +++ b/rasa/core/constants.py @@ -40,7 +40,8 @@ BEARER_TOKEN_PREFIX = "Bearer " -# Key to access data in the event metadata which specifies if an event was caused by an external entity (e.g. a sensor). +# Key to access data in the event metadata +# It specifies if an event was caused by an external entity (e.g. a sensor). IS_EXTERNAL = "is_external" # the lowest priority intended to be used by machine learning policies diff --git a/rasa/core/run.py b/rasa/core/run.py index e105caf55dc5..0fafd189bc34 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -162,6 +162,8 @@ def serve_application( ssl_password: Optional[Text] = None, conversation_id: Optional[Text] = uuid.uuid4().hex, ): + """Run the API entrypoint.""" + from rasa import server if not channel and not credentials: diff --git a/rasa/server.py b/rasa/server.py index a31bdbf7c301..0ff8129d36e9 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -40,11 +40,11 @@ from rasa.nlu.emulators.no_emulator import NoEmulator from rasa.nlu.test import run_evaluation from rasa.utils.endpoints import EndpointConfig -from sanic import Sanic, Sanic, response, response -from sanic.request import Request, Request +from sanic import Sanic, response +from sanic.request import Request from sanic.response import HTTPResponse -from sanic_cors import CORS, CORS -from sanic_jwt import Initialize, Initialize, exceptions, exceptions +from sanic_cors import CORS +from sanic_jwt import Initialize, exceptions if typing.TYPE_CHECKING: from ssl import SSLContext @@ -195,6 +195,8 @@ async def decorated(request: Request, *args: Any, **kwargs: Any) -> Any: def event_verbosity_parameter( request: Request, default_verbosity: EventVerbosity ) -> EventVerbosity: + """Create EventVerbosity object using request params if present.""" + event_verbosity_str = request.args.get( "include_events", default_verbosity.name ).upper() @@ -214,6 +216,8 @@ def event_verbosity_parameter( async def get_tracker( processor: "MessageProcessor", conversation_id: Text ) -> Optional[DialogueStateTracker]: + """Get tracker object from MessageProcessor""" + tracker = await processor.get_tracker_with_session_start(conversation_id) if not tracker: raise ErrorResponse( @@ -226,11 +230,15 @@ async def get_tracker( def validate_request_body(request: Request, error_message: Text): + """Check if the request has a body.""" + if not request.body: raise ErrorResponse(400, "BadRequest", error_message) async def authenticate(request: Request): + """Callback for authentication failed.""" + raise exceptions.AuthenticationFailed( "Direct JWT authentication not supported. You should already have " "a valid JWT from an authentication provider, Rasa will just make " @@ -363,6 +371,8 @@ def configure_cors( def add_root_route(app: Sanic): + """Add / route to return hello.""" + @app.get("/") async def hello(request: Request): """Check if the server is running and responds with the version.""" From 0c6ac73c88b81095a85bee6a6f12d468adeb98a8 Mon Sep 17 00:00:00 2001 From: mmalhotra Date: Mon, 16 Mar 2020 15:32:09 -0400 Subject: [PATCH 05/24] fix tests --- tests/cli/test_rasa_run.py | 3 ++- tests/cli/test_rasa_shell.py | 2 +- tests/cli/test_rasa_x.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/cli/test_rasa_run.py b/tests/cli/test_rasa_run.py index 9975ad4bf677..daa42036a7f6 100644 --- a/tests/cli/test_rasa_run.py +++ b/tests/cli/test_rasa_run.py @@ -20,7 +20,8 @@ def test_run_help(run: Callable[..., RunResult]): help_text = """usage: rasa run [-h] [-v] [-vv] [--quiet] [-m MODEL] [--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN] - [--response-timeout RESPONSE_TIMEOUT] [--cors [CORS [CORS ...]]] [--enable-api] + [--cors [CORS [CORS ...]]] [--enable-api] + [--response-timeout RESPONSE_TIMEOUT] [--remote-storage REMOTE_STORAGE] [--ssl-certificate SSL_CERTIFICATE] [--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE] diff --git a/tests/cli/test_rasa_shell.py b/tests/cli/test_rasa_shell.py index f6c2d5d5c457..bb7f7cc99fc9 100644 --- a/tests/cli/test_rasa_shell.py +++ b/tests/cli/test_rasa_shell.py @@ -8,8 +8,8 @@ def test_shell_help(run: Callable[..., RunResult]): help_text = """usage: rasa shell [-h] [-v] [-vv] [--quiet] [--conversation-id CONVERSATION_ID] [-m MODEL] [--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT] - [--response-timeout RESPONSE_TIMEOUT] [-t AUTH_TOKEN] [--cors [CORS [CORS ...]]] [--enable-api] + [--response-timeout RESPONSE_TIMEOUT] [--remote-storage REMOTE_STORAGE] [--ssl-certificate SSL_CERTIFICATE] [--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE] diff --git a/tests/cli/test_rasa_x.py b/tests/cli/test_rasa_x.py index 852994b50d28..1aabc643b223 100644 --- a/tests/cli/test_rasa_x.py +++ b/tests/cli/test_rasa_x.py @@ -20,8 +20,8 @@ def test_x_help(run: Callable[..., RunResult]): [--no-prompt] [--production] [--rasa-x-port RASA_X_PORT] [--config-endpoint CONFIG_ENDPOINT] [--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT] [-t AUTH_TOKEN] - [--response-timeout RESPONSE_TIMEOUT] [--cors [CORS [CORS ...]]] [--enable-api] + [--response-timeout RESPONSE_TIMEOUT] [--remote-storage REMOTE_STORAGE] [--ssl-certificate SSL_CERTIFICATE] [--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE] [--ssl-password SSL_PASSWORD] From fc658829d77fd57584316d38936432cdaf66b9f9 Mon Sep 17 00:00:00 2001 From: mmalhotra Date: Mon, 16 Mar 2020 15:39:18 -0400 Subject: [PATCH 06/24] fix changelog --- changelog/4756.improvement.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/changelog/4756.improvement.rst b/changelog/4756.improvement.rst index f506a2c9c6ae..685ee8bbd425 100644 --- a/changelog/4756.improvement.rst +++ b/changelog/4756.improvement.rst @@ -1,3 +1,4 @@ -Make Rasa server response timeout configurable. -Rasa server can now be started with ``--response-timeout `` to configure a +Make response timeout configurable. +`rasa run`, `rasa shell` and `rasa x` +can now be started with ``--response-timeout `` to configure a response timeout of ```` seconds. From 270cfb00f32e5283daa8d73e3bfac0b78dc51db2 Mon Sep 17 00:00:00 2001 From: mmalhotra Date: Mon, 16 Mar 2020 15:42:44 -0400 Subject: [PATCH 07/24] fix changelog --- changelog/4756.improvement.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/changelog/4756.improvement.rst b/changelog/4756.improvement.rst index 685ee8bbd425..09921a995ace 100644 --- a/changelog/4756.improvement.rst +++ b/changelog/4756.improvement.rst @@ -1,4 +1,3 @@ Make response timeout configurable. -`rasa run`, `rasa shell` and `rasa x` -can now be started with ``--response-timeout `` to configure a -response timeout of ```` seconds. +``rasa run``, ``rasa shell`` and ``rasa x`` can now be started with +``--response-timeout `` to configure a response timeout of ```` seconds. From 1a37b9108596aba5a48124b78aa41ab3c5441776 Mon Sep 17 00:00:00 2001 From: mmalhotra Date: Mon, 16 Mar 2020 15:42:44 -0400 Subject: [PATCH 08/24] Fix changelog --- changelog/4756.improvement.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/changelog/4756.improvement.rst b/changelog/4756.improvement.rst index 685ee8bbd425..09921a995ace 100644 --- a/changelog/4756.improvement.rst +++ b/changelog/4756.improvement.rst @@ -1,4 +1,3 @@ Make response timeout configurable. -`rasa run`, `rasa shell` and `rasa x` -can now be started with ``--response-timeout `` to configure a -response timeout of ```` seconds. +``rasa run``, ``rasa shell`` and ``rasa x`` can now be started with +``--response-timeout `` to configure a response timeout of ```` seconds. From fc3dadd6d7bf649cc742acd03f44a6f383a28ea5 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:49:11 -0400 Subject: [PATCH 09/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index 0ff8129d36e9..793d2e45d734 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -195,7 +195,7 @@ async def decorated(request: Request, *args: Any, **kwargs: Any) -> Any: def event_verbosity_parameter( request: Request, default_verbosity: EventVerbosity ) -> EventVerbosity: - """Create EventVerbosity object using request params if present.""" + """Create `EventVerbosity` object using request params if present.""" event_verbosity_str = request.args.get( "include_events", default_verbosity.name From dd69268cba2b30484c6d2d57b45dfc0b8d97b6a8 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:49:22 -0400 Subject: [PATCH 10/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index 793d2e45d734..0fc82b9ad9e5 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -216,7 +216,7 @@ def event_verbosity_parameter( async def get_tracker( processor: "MessageProcessor", conversation_id: Text ) -> Optional[DialogueStateTracker]: - """Get tracker object from MessageProcessor""" + """Get tracker object from `MessageProcessor`.""" tracker = await processor.get_tracker_with_session_start(conversation_id) if not tracker: From de14033c55619b89d1668da517644a98d4fa7cca Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:49:34 -0400 Subject: [PATCH 11/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index 0fc82b9ad9e5..ecc8ab324b34 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -371,7 +371,7 @@ def configure_cors( def add_root_route(app: Sanic): - """Add / route to return hello.""" + """Add '/' route to return hello.""" @app.get("/") async def hello(request: Request): From 642ccc3b06a9942889c91b3899c7c743659d3a59 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:49:45 -0400 Subject: [PATCH 12/24] Update rasa/cli/arguments/run.py Co-Authored-By: ricwo --- rasa/cli/arguments/run.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/cli/arguments/run.py b/rasa/cli/arguments/run.py index 6c1f7fe5b029..fce0cca29028 100644 --- a/rasa/cli/arguments/run.py +++ b/rasa/cli/arguments/run.py @@ -13,7 +13,6 @@ def set_run_arguments(parser: argparse.ArgumentParser): def set_run_action_arguments(parser: argparse.ArgumentParser): """Set arguments for running action sdk.""" - import rasa_sdk.cli.arguments as sdk sdk.add_endpoint_arguments(parser) From 5b3c94f78ca3f8434fe621551f9f7855afe2765d Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:49:55 -0400 Subject: [PATCH 13/24] Update rasa/cli/arguments/run.py Co-Authored-By: ricwo --- rasa/cli/arguments/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/cli/arguments/run.py b/rasa/cli/arguments/run.py index fce0cca29028..cb589db87ad9 100644 --- a/rasa/cli/arguments/run.py +++ b/rasa/cli/arguments/run.py @@ -12,7 +12,7 @@ def set_run_arguments(parser: argparse.ArgumentParser): def set_run_action_arguments(parser: argparse.ArgumentParser): - """Set arguments for running action sdk.""" + """Set arguments for running Rasa SDK.""" import rasa_sdk.cli.arguments as sdk sdk.add_endpoint_arguments(parser) From 6ad8ddfeb34770d455285082ab392dc18f3c805a Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:50:05 -0400 Subject: [PATCH 14/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index ecc8ab324b34..f92011accf30 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -231,7 +231,6 @@ async def get_tracker( def validate_request_body(request: Request, error_message: Text): """Check if the request has a body.""" - if not request.body: raise ErrorResponse(400, "BadRequest", error_message) From 08a781bb0d94474e8ac192f12111cc501348fd30 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:50:18 -0400 Subject: [PATCH 15/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index f92011accf30..fc32f90488a2 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -230,7 +230,7 @@ async def get_tracker( def validate_request_body(request: Request, error_message: Text): - """Check if the request has a body.""" + """Check if `request` has a body.""" if not request.body: raise ErrorResponse(400, "BadRequest", error_message) From 1d8d994480ea74dee42cf1ead53ef90eddc1ce71 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:50:29 -0400 Subject: [PATCH 16/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index fc32f90488a2..fc75e23f21fe 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -371,7 +371,6 @@ def configure_cors( def add_root_route(app: Sanic): """Add '/' route to return hello.""" - @app.get("/") async def hello(request: Request): """Check if the server is running and responds with the version.""" From 79c5875b3b1eb1c53a6cee7e3585ca1e82230b1b Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:50:39 -0400 Subject: [PATCH 17/24] Update rasa/cli/arguments/run.py Co-Authored-By: ricwo --- rasa/cli/arguments/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rasa/cli/arguments/run.py b/rasa/cli/arguments/run.py index cb589db87ad9..2b9887a3feea 100644 --- a/rasa/cli/arguments/run.py +++ b/rasa/cli/arguments/run.py @@ -5,7 +5,7 @@ def set_run_arguments(parser: argparse.ArgumentParser): - """Arguments for running rasa directly.""" + """Arguments for running Rasa directly using `rasa run`.""" add_model_param(parser) add_server_arguments(parser) From 51e2237a35dcfc9872d985b270fd09fc6254cd12 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:50:57 -0400 Subject: [PATCH 18/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index fc75e23f21fe..01cc300b8422 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -237,7 +237,6 @@ def validate_request_body(request: Request, error_message: Text): async def authenticate(request: Request): """Callback for authentication failed.""" - raise exceptions.AuthenticationFailed( "Direct JWT authentication not supported. You should already have " "a valid JWT from an authentication provider, Rasa will just make " From 1618167841fe2c247912ac5ae68996aa55795ee1 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:51:13 -0400 Subject: [PATCH 19/24] Update rasa/cli/arguments/run.py Co-Authored-By: ricwo --- rasa/cli/arguments/run.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/cli/arguments/run.py b/rasa/cli/arguments/run.py index 2b9887a3feea..d19654c53108 100644 --- a/rasa/cli/arguments/run.py +++ b/rasa/cli/arguments/run.py @@ -6,7 +6,6 @@ def set_run_arguments(parser: argparse.ArgumentParser): """Arguments for running Rasa directly using `rasa run`.""" - add_model_param(parser) add_server_arguments(parser) From 66d992967fc416de2fda911592132f1d7d4c0185 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:51:26 -0400 Subject: [PATCH 20/24] Update rasa/cli/arguments/run.py Co-Authored-By: ricwo --- rasa/cli/arguments/run.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/cli/arguments/run.py b/rasa/cli/arguments/run.py index d19654c53108..00290ec499fa 100644 --- a/rasa/cli/arguments/run.py +++ b/rasa/cli/arguments/run.py @@ -19,7 +19,6 @@ def set_run_action_arguments(parser: argparse.ArgumentParser): def add_server_arguments(parser: argparse.ArgumentParser): """Add arguments for running API endpoint.""" - parser.add_argument( "--log-file", type=str, From 463dde89c85a380bec8103111a407a4e77464ee5 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:51:39 -0400 Subject: [PATCH 21/24] Update rasa/core/run.py Co-Authored-By: ricwo --- rasa/core/run.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/core/run.py b/rasa/core/run.py index 0fafd189bc34..212ccb6f7a81 100644 --- a/rasa/core/run.py +++ b/rasa/core/run.py @@ -163,7 +163,6 @@ def serve_application( conversation_id: Optional[Text] = uuid.uuid4().hex, ): """Run the API entrypoint.""" - from rasa import server if not channel and not credentials: From b45ed0fc3aa15423e18c2685a4dca9fc4c5a1113 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:51:53 -0400 Subject: [PATCH 22/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index 01cc300b8422..fac43f2dcb0d 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -196,7 +196,6 @@ def event_verbosity_parameter( request: Request, default_verbosity: EventVerbosity ) -> EventVerbosity: """Create `EventVerbosity` object using request params if present.""" - event_verbosity_str = request.args.get( "include_events", default_verbosity.name ).upper() From 08ea3137e361f283414fc110766fcf8f91dfb2b1 Mon Sep 17 00:00:00 2001 From: Manik Malhotra <34263822+mmalhotra@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:52:10 -0400 Subject: [PATCH 23/24] Update rasa/server.py Co-Authored-By: ricwo --- rasa/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rasa/server.py b/rasa/server.py index fac43f2dcb0d..54bb896b9fb3 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -216,7 +216,6 @@ async def get_tracker( processor: "MessageProcessor", conversation_id: Text ) -> Optional[DialogueStateTracker]: """Get tracker object from `MessageProcessor`.""" - tracker = await processor.get_tracker_with_session_start(conversation_id) if not tracker: raise ErrorResponse( From 180a6f1665b27c5a12d53e41915c46c208e17451 Mon Sep 17 00:00:00 2001 From: mmalhotra Date: Tue, 17 Mar 2020 08:04:14 -0400 Subject: [PATCH 24/24] fix black issue --- rasa/server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rasa/server.py b/rasa/server.py index 54bb896b9fb3..b3940f11bf42 100644 --- a/rasa/server.py +++ b/rasa/server.py @@ -368,6 +368,7 @@ def configure_cors( def add_root_route(app: Sanic): """Add '/' route to return hello.""" + @app.get("/") async def hello(request: Request): """Check if the server is running and responds with the version."""