From 414c720e7cb4d9e7060bc782548f5dfa969f72f8 Mon Sep 17 00:00:00 2001 From: Michal Hubatka Date: Tue, 20 Feb 2024 09:50:15 +0100 Subject: [PATCH 1/3] OSS-757 configurable client timeouts --- rasa/utils/endpoints.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rasa/utils/endpoints.py b/rasa/utils/endpoints.py index 31d1ea7228bc..c470e6b80d46 100644 --- a/rasa/utils/endpoints.py +++ b/rasa/utils/endpoints.py @@ -89,6 +89,7 @@ def __init__( token: Optional[Text] = None, token_name: Text = "token", cafile: Optional[Text] = None, + client_timeout: Optional[Dict[Text, Any]] = None, **kwargs: Any, ) -> None: """Creates an `EndpointConfig` instance.""" @@ -100,6 +101,7 @@ def __init__( self.token_name = token_name self.type = kwargs.pop("store_type", kwargs.pop("type", None)) self.cafile = cafile + self.client_timeout = client_timeout or {"total": DEFAULT_REQUEST_TIMEOUT} self.kwargs = kwargs def session(self) -> aiohttp.ClientSession: @@ -115,7 +117,7 @@ def session(self) -> aiohttp.ClientSession: return aiohttp.ClientSession( headers=self.headers, auth=auth, - timeout=aiohttp.ClientTimeout(total=DEFAULT_REQUEST_TIMEOUT), + timeout=aiohttp.ClientTimeout(**self.client_timeout), ) def combine_parameters( @@ -203,6 +205,7 @@ def copy(self) -> "EndpointConfig": self.basic_auth, self.token, self.token_name, + self.client_timeout, **self.kwargs, ) From 67316881e6ba04ec6bfacee924653ac0fdc2b243 Mon Sep 17 00:00:00 2001 From: Michal Hubatka Date: Tue, 20 Feb 2024 10:00:05 +0100 Subject: [PATCH 2/3] OSS-757 adds changelog --- changelog/13015.improvement.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/13015.improvement.md diff --git a/changelog/13015.improvement.md b/changelog/13015.improvement.md new file mode 100644 index 000000000000..655fadf43c26 --- /dev/null +++ b/changelog/13015.improvement.md @@ -0,0 +1 @@ +Users can now specify client_timeout in the YAML configuration file to customize timeout durations for HTTP requests made by Rasa \ No newline at end of file From 954a76013fbfbf521b76870721619904eaf10b83 Mon Sep 17 00:00:00 2001 From: Michal Hubatka Date: Tue, 20 Feb 2024 10:01:50 +0100 Subject: [PATCH 3/3] OSS-757 removes timeouts --- rasa/core/actions/action.py | 2 -- rasa/core/agent.py | 2 -- rasa/core/nlg/callback.py | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/rasa/core/actions/action.py b/rasa/core/actions/action.py index 8c511100916e..a13556047071 100644 --- a/rasa/core/actions/action.py +++ b/rasa/core/actions/action.py @@ -17,7 +17,6 @@ import rasa.core from rasa.core.actions.constants import DEFAULT_SELECTIVE_DOMAIN, SELECTIVE_DOMAIN from rasa.core.constants import ( - DEFAULT_REQUEST_TIMEOUT, COMPRESS_ACTION_SERVER_REQUEST_ENV_NAME, DEFAULT_COMPRESS_ACTION_SERVER_REQUEST, ) @@ -780,7 +779,6 @@ async def run( response: Any = await self.action_endpoint.request( json=modified_json if modified_json else json_body, method="post", - timeout=DEFAULT_REQUEST_TIMEOUT, compress=should_compress, ) if modified_json: diff --git a/rasa/core/agent.py b/rasa/core/agent.py index 47e3360f6a5b..e672aba18d9b 100644 --- a/rasa/core/agent.py +++ b/rasa/core/agent.py @@ -12,7 +12,6 @@ from rasa.core import jobs from rasa.core.channels.channel import OutputChannel, UserMessage -from rasa.core.constants import DEFAULT_REQUEST_TIMEOUT from rasa.core.http_interpreter import RasaNLUHttpInterpreter from rasa.shared.core.domain import Domain from rasa.core.exceptions import AgentNotReady @@ -118,7 +117,6 @@ async def _pull_model_and_fingerprint( async with session.request( "GET", model_server.url, - timeout=DEFAULT_REQUEST_TIMEOUT, headers=headers, params=params, ) as resp: diff --git a/rasa/core/nlg/callback.py b/rasa/core/nlg/callback.py index d997f6ace092..abc5107211ea 100644 --- a/rasa/core/nlg/callback.py +++ b/rasa/core/nlg/callback.py @@ -88,7 +88,7 @@ async def generate( ) response = await self.nlg_endpoint.request( - method="post", json=body, timeout=DEFAULT_REQUEST_TIMEOUT + method="post", json=body ) logger.debug(f"Received NLG response: {json.dumps(response)}")