From 18941dbaddfcc231d2ac3d52e2d5304d29abef9e Mon Sep 17 00:00:00 2001 From: Tanja Bunk Date: Mon, 20 Nov 2023 11:08:24 +0100 Subject: [PATCH 1/4] catch deprecation warnings from sanic --- rasa_sdk/endpoint.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rasa_sdk/endpoint.py b/rasa_sdk/endpoint.py index d923aa7d1..8f4e77f01 100644 --- a/rasa_sdk/endpoint.py +++ b/rasa_sdk/endpoint.py @@ -2,6 +2,7 @@ import logging import os import types +import warnings import zlib import json from opentelemetry.sdk.trace import TracerProvider @@ -11,7 +12,9 @@ from sanic import Sanic, response from sanic.response import HTTPResponse from sanic.request import Request -from sanic_cors import CORS +with warnings.catch_warnings(): + warnings.filterwarnings("ignore",category=DeprecationWarning) + from sanic_cors import CORS from rasa_sdk import utils from rasa_sdk.cli.arguments import add_endpoint_arguments From d406c9491fe4a6f4e7347a409dc07ab21f189e85 Mon Sep 17 00:00:00 2001 From: Tanja Bunk Date: Mon, 20 Nov 2023 11:11:38 +0100 Subject: [PATCH 2/4] formatting --- rasa_sdk/endpoint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rasa_sdk/endpoint.py b/rasa_sdk/endpoint.py index 8f4e77f01..7facf1bc4 100644 --- a/rasa_sdk/endpoint.py +++ b/rasa_sdk/endpoint.py @@ -12,8 +12,9 @@ from sanic import Sanic, response from sanic.response import HTTPResponse from sanic.request import Request + with warnings.catch_warnings(): - warnings.filterwarnings("ignore",category=DeprecationWarning) + warnings.filterwarnings("ignore", category=DeprecationWarning) from sanic_cors import CORS from rasa_sdk import utils From 6a90ae61959c33c7913fbdc5ab8d2624ea227fd3 Mon Sep 17 00:00:00 2001 From: OgnjenFrancuski Date: Wed, 22 Nov 2023 12:55:59 +0100 Subject: [PATCH 3/4] Add a more inclusive warnings contex manager --- rasa_sdk/endpoint.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/rasa_sdk/endpoint.py b/rasa_sdk/endpoint.py index 7facf1bc4..e8a94f791 100644 --- a/rasa_sdk/endpoint.py +++ b/rasa_sdk/endpoint.py @@ -5,25 +5,31 @@ import warnings import zlib import json -from opentelemetry.sdk.trace import TracerProvider from typing import List, Text, Union, Optional from ssl import SSLContext - from sanic import Sanic, response from sanic.response import HTTPResponse -from sanic.request import Request - +# catching: +# - all `pkg_resources` deprecation warning from multiple dependencies +# - google rcp warnings (`pkg_resources.namespaces`) +# - open telemetry (`pkg_resources`) +# - sanic-cors (`distutils Version classes...`) with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) + warnings.filterwarnings( + "ignore", category=DeprecationWarning, message=".*pkg_resources.*") + warnings.filterwarnings( + "ignore", category=DeprecationWarning, + message="distutils Version classes are deprecated") + from opentelemetry.sdk.trace import TracerProvider from sanic_cors import CORS - -from rasa_sdk import utils -from rasa_sdk.cli.arguments import add_endpoint_arguments -from rasa_sdk.constants import DEFAULT_KEEP_ALIVE_TIMEOUT, DEFAULT_SERVER_PORT -from rasa_sdk.executor import ActionExecutor -from rasa_sdk.interfaces import ActionExecutionRejection, ActionNotFoundException -from rasa_sdk.plugin import plugin_manager -from rasa_sdk.tracing.utils import get_tracer_and_context, set_span_attributes + from sanic.request import Request + from rasa_sdk import utils + from rasa_sdk.cli.arguments import add_endpoint_arguments + from rasa_sdk.constants import DEFAULT_KEEP_ALIVE_TIMEOUT, DEFAULT_SERVER_PORT + from rasa_sdk.executor import ActionExecutor + from rasa_sdk.interfaces import ActionExecutionRejection, ActionNotFoundException + from rasa_sdk.plugin import plugin_manager + from rasa_sdk.tracing.utils import get_tracer_and_context, set_span_attributes logger = logging.getLogger(__name__) From 68f0b3b390dec3571d1995f45f3becd25c1ebd14 Mon Sep 17 00:00:00 2001 From: OgnjenFrancuski Date: Wed, 22 Nov 2023 13:00:09 +0100 Subject: [PATCH 4/4] Fix lint --- rasa_sdk/endpoint.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rasa_sdk/endpoint.py b/rasa_sdk/endpoint.py index e8a94f791..eb922c51a 100644 --- a/rasa_sdk/endpoint.py +++ b/rasa_sdk/endpoint.py @@ -9,6 +9,7 @@ from ssl import SSLContext from sanic import Sanic, response from sanic.response import HTTPResponse + # catching: # - all `pkg_resources` deprecation warning from multiple dependencies # - google rcp warnings (`pkg_resources.namespaces`) @@ -16,10 +17,13 @@ # - sanic-cors (`distutils Version classes...`) with warnings.catch_warnings(): warnings.filterwarnings( - "ignore", category=DeprecationWarning, message=".*pkg_resources.*") + "ignore", category=DeprecationWarning, message=".*pkg_resources.*" + ) warnings.filterwarnings( - "ignore", category=DeprecationWarning, - message="distutils Version classes are deprecated") + "ignore", + category=DeprecationWarning, + message="distutils Version classes are deprecated", + ) from opentelemetry.sdk.trace import TracerProvider from sanic_cors import CORS from sanic.request import Request