Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSS-757 configurable client timeouts #13015

Open
wants to merge 3 commits into
base: 3.6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/13015.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Users can now specify client_timeout in the YAML configuration file to customize timeout durations for HTTP requests made by Rasa
2 changes: 0 additions & 2 deletions rasa/core/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions rasa/core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/nlg/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")
Expand Down
5 changes: 4 additions & 1 deletion rasa/utils/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -203,6 +205,7 @@ def copy(self) -> "EndpointConfig":
self.basic_auth,
self.token,
self.token_name,
self.client_timeout,
**self.kwargs,
)

Expand Down