Skip to content

Commit

Permalink
Add a more inclusive warnings contex manager
Browse files Browse the repository at this point in the history
  • Loading branch information
OgnjenFrancuski committed Nov 22, 2023
1 parent 1059a32 commit 4265e27
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions rasa_sdk/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_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_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__)

Expand Down

0 comments on commit 4265e27

Please sign in to comment.