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

[Serve] use serve logger name for logs in serve #47205

Merged
merged 3 commits into from
Aug 20, 2024
Merged
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
3 changes: 2 additions & 1 deletion python/ray/serve/_private/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
HTTP_PROXY_TIMEOUT,
RAY_SERVE_ENABLE_TASK_EVENTS,
SERVE_CONTROLLER_NAME,
SERVE_LOGGER_NAME,
SERVE_NAMESPACE,
)
from ray.serve._private.controller import ServeController
Expand All @@ -23,7 +24,7 @@
from ray.serve.exceptions import RayServeException
from ray.serve.schema import LoggingConfig

logger = logging.getLogger(__file__)
logger = logging.getLogger(SERVE_LOGGER_NAME)


def get_deployment(name: str, app_name: str = ""):
Expand Down
3 changes: 2 additions & 1 deletion python/ray/serve/_private/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CLIENT_POLLING_INTERVAL_S,
MAX_CACHED_HANDLES,
SERVE_DEFAULT_APP_NAME,
SERVE_LOGGER_NAME,
)
from ray.serve._private.controller import ServeController
from ray.serve._private.deploy_utils import get_deploy_args
Expand All @@ -34,7 +35,7 @@
from ray.serve.handle import DeploymentHandle, _HandleOptions
from ray.serve.schema import LoggingConfig, ServeApplicationSchema, ServeDeploySchema

logger = logging.getLogger(__file__)
logger = logging.getLogger(SERVE_LOGGER_NAME)


def _ensure_connected(f: Callable) -> Callable:
Expand Down
8 changes: 6 additions & 2 deletions python/ray/serve/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
from ray.serve._private.client import ServeControllerClient
from ray.serve._private.common import ReplicaID
from ray.serve._private.config import DeploymentConfig
from ray.serve._private.constants import SERVE_CONTROLLER_NAME, SERVE_NAMESPACE
from ray.serve._private.constants import (
SERVE_CONTROLLER_NAME,
SERVE_LOGGER_NAME,
SERVE_NAMESPACE,
)
from ray.serve.exceptions import RayServeException
from ray.serve.grpc_util import RayServegRPCContext
from ray.util.annotations import DeveloperAPI

logger = logging.getLogger(__file__)
logger = logging.getLogger(SERVE_LOGGER_NAME)

_INTERNAL_REPLICA_CONTEXT: "ReplicaContext" = None
_global_client: ServeControllerClient = None
Expand Down
3 changes: 2 additions & 1 deletion python/ray/serve/gradio_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Callable

from ray import serve
from ray.serve._private.constants import SERVE_LOGGER_NAME
from ray.serve._private.http_util import ASGIAppReplicaWrapper
from ray.util.annotations import PublicAPI

Expand All @@ -11,7 +12,7 @@
print("Gradio isn't installed. Run `pip install gradio` to install Gradio.")
raise

logger = logging.getLogger(__file__)
logger = logging.getLogger(SERVE_LOGGER_NAME)


@PublicAPI(stability="alpha")
Expand Down
16 changes: 14 additions & 2 deletions python/ray/serve/tests/test_standalone_3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import subprocess
import sys
Expand All @@ -15,7 +16,7 @@
from ray.cluster_utils import AutoscalingCluster, Cluster
from ray.exceptions import RayActorError
from ray.serve._private.common import ProxyStatus
from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME
from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME, SERVE_LOGGER_NAME
from ray.serve._private.logging_utils import get_serve_logs_dir
from ray.serve._private.utils import get_head_node_id
from ray.serve.context import _get_global_client
Expand Down Expand Up @@ -595,6 +596,17 @@ def test_client_shutdown_gracefully_when_timeout(
log timeout message and exit the process. The controller will continue to shutdown
everything gracefully.
"""
logger = logging.getLogger(SERVE_LOGGER_NAME)
caplog.set_level(logging.WARNING, logger=SERVE_LOGGER_NAME)

warning_msg = []

class WarningHandler(logging.Handler):
def emit(self, record):
warning_msg.append(self.format(record))

logger.addHandler(WarningHandler())

# Setup a cluster with 2 nodes
cluster = Cluster()
cluster.add_node()
Expand All @@ -621,7 +633,7 @@ def __call__(self):
client.shutdown(timeout_s=timeout_s)
assert (
f"Controller failed to shut down within {timeout_s}s. "
f"Check controller logs for more details." in caplog.text
f"Check controller logs for more details." in warning_msg
)

# Ensure the all resources are shutdown gracefully.
Expand Down