mirror of
https://github.com/vale981/ray
synced 2025-03-05 18:11:42 -05:00
[Serve] Remove the warning for async handles in 2.0 (#27346)
Signed-off-by: simon-mo <simon.mo@hey.com>
This commit is contained in:
parent
c8561071f3
commit
a9d94f740c
2 changed files with 6 additions and 46 deletions
|
@ -1,4 +1,3 @@
|
|||
import asyncio
|
||||
import atexit
|
||||
import logging
|
||||
import random
|
||||
|
@ -23,9 +22,6 @@ from ray.serve.handle import RayServeHandle, RayServeSyncHandle
|
|||
from ray.serve.schema import ServeApplicationSchema
|
||||
|
||||
logger = logging.getLogger(__file__)
|
||||
# Whether to issue warnings about using sync handles in async context
|
||||
# or using async handle in sync context.
|
||||
_WARN_SYNC_ASYNC_HANDLE_CONTEXT: bool = True
|
||||
|
||||
|
||||
def _ensure_connected(f: Callable) -> Callable:
|
||||
|
@ -367,31 +363,6 @@ class ServeControllerClient:
|
|||
if not missing_ok and deployment_name not in all_endpoints:
|
||||
raise KeyError(f"Deployment '{deployment_name}' does not exist.")
|
||||
|
||||
try:
|
||||
asyncio_loop_running = asyncio.get_event_loop().is_running()
|
||||
except RuntimeError as ex:
|
||||
if "There is no current event loop in thread" in str(ex):
|
||||
asyncio_loop_running = False
|
||||
else:
|
||||
raise ex
|
||||
|
||||
if asyncio_loop_running and sync and _WARN_SYNC_ASYNC_HANDLE_CONTEXT:
|
||||
logger.warning(
|
||||
"You are retrieving a sync handle inside an asyncio loop. "
|
||||
"Try getting Deployment.get_handle(.., sync=False) to get better "
|
||||
"performance. Learn more at https://docs.ray.io/en/latest/serve/"
|
||||
"handle-guide.html#sync-and-async-handles"
|
||||
)
|
||||
|
||||
if not asyncio_loop_running and not sync and _WARN_SYNC_ASYNC_HANDLE_CONTEXT:
|
||||
logger.warning(
|
||||
"You are retrieving an async handle outside an asyncio loop. "
|
||||
"You should make sure Deployment.get_handle is called inside a "
|
||||
"running event loop. Or call Deployment.get_handle(.., sync=True) "
|
||||
"to create sync handle. Learn more at https://docs.ray.io/en/latest/"
|
||||
"serve/handle-guide.html#sync-and-async-handles"
|
||||
)
|
||||
|
||||
if sync:
|
||||
handle = RayServeSyncHandle(
|
||||
self._controller,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from contextlib import contextmanager
|
||||
import json
|
||||
|
||||
from ray.dag.class_node import ClassNode # noqa: F401
|
||||
|
@ -6,14 +5,6 @@ from ray.dag.function_node import FunctionNode # noqa: F401
|
|||
from ray.dag.input_node import InputNode # noqa: F401
|
||||
from ray.dag import DAGNode # noqa: F401
|
||||
from ray.util.annotations import PublicAPI
|
||||
import ray.serve._private.client
|
||||
|
||||
|
||||
@contextmanager
|
||||
def _mute_sync_handle_warnings():
|
||||
ray.serve._private.client._WARN_SYNC_ASYNC_HANDLE_CONTEXT = False
|
||||
yield
|
||||
ray.serve._private.client._WARN_SYNC_ASYNC_HANDLE_CONTEXT = True
|
||||
|
||||
|
||||
@PublicAPI(stability="alpha")
|
||||
|
@ -41,12 +32,10 @@ class RayServeDAGHandle:
|
|||
return RayServeDAGHandle._deserialize, (self.dag_node_json,)
|
||||
|
||||
def remote(self, *args, **kwargs):
|
||||
# NOTE: There's nothing user can do about these warnings, we should hide it.
|
||||
with _mute_sync_handle_warnings():
|
||||
if self.dag_node is None:
|
||||
from ray.serve._private.json_serde import dagnode_from_json
|
||||
if self.dag_node is None:
|
||||
from ray.serve._private.json_serde import dagnode_from_json
|
||||
|
||||
self.dag_node = json.loads(
|
||||
self.dag_node_json, object_hook=dagnode_from_json
|
||||
)
|
||||
return self.dag_node.execute(*args, **kwargs)
|
||||
self.dag_node = json.loads(
|
||||
self.dag_node_json, object_hook=dagnode_from_json
|
||||
)
|
||||
return self.dag_node.execute(*args, **kwargs)
|
||||
|
|
Loading…
Add table
Reference in a new issue