From 86ccfc2833bab553257b7de952be6c611acab445 Mon Sep 17 00:00:00 2001 From: vitrioil Date: Sun, 25 Sep 2022 23:34:24 +0530 Subject: [PATCH 1/3] Fix log format for serve Signed-off-by: vitrioil --- python/ray/serve/_private/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/ray/serve/_private/api.py b/python/ray/serve/_private/api.py index 935e75beb358..eb646428dc9e 100644 --- a/python/ray/serve/_private/api.py +++ b/python/ray/serve/_private/api.py @@ -171,8 +171,8 @@ def serve_start( try: client = get_global_client(_health_check_controller=True) logger.info( - f'Connecting to existing Serve app in namespace "{SERVE_NAMESPACE}".', - " New http options will not be applied.", + f'Connecting to existing Serve app in namespace "{SERVE_NAMESPACE}".' + " New http options will not be applied." ) _check_http_options(client, http_options) From 2d41f761c40ee03401bf16ee36d344d20f549042 Mon Sep 17 00:00:00 2001 From: vitrioil Date: Tue, 8 Nov 2022 21:28:51 +0530 Subject: [PATCH 2/3] Add test for serve start log --- python/ray/serve/tests/test_logs.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/python/ray/serve/tests/test_logs.py b/python/ray/serve/tests/test_logs.py index 8c6fc3b08527..f28b38572afa 100644 --- a/python/ray/serve/tests/test_logs.py +++ b/python/ray/serve/tests/test_logs.py @@ -84,3 +84,28 @@ def __init__(self): assert "Exception in deployment 'D'" in captured.err assert "ZeroDivisionError" in captured.err + + +def test_connect_serve_start_logging(serve_instance, capsys): + import logging + logging.basicConfig(level=logging.INFO) + + @serve.deployment + class D: + def __init__(self): + pass + + serve.run(D.options().bind(), _blocking=False) + + expected_log = ( + 'Connecting to existing Serve app in namespace "serve"' + '. New http options will not be applied.' + ) + + # wait long enough for the warning to be printed + # with a small grace period + time.sleep(SLOW_STARTUP_WARNING_PERIOD_S * 1.5) + + captured = capsys.readouterr() + + assert expected_log in captured.err From ff54efd7a5178bf7372d71795468bbfa7137aa03 Mon Sep 17 00:00:00 2001 From: vitrioil Date: Wed, 9 Nov 2022 19:10:08 +0530 Subject: [PATCH 3/3] Fix lint Signed-off-by: vitrioil --- python/ray/serve/tests/test_logs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/ray/serve/tests/test_logs.py b/python/ray/serve/tests/test_logs.py index f28b38572afa..9b633a50ad88 100644 --- a/python/ray/serve/tests/test_logs.py +++ b/python/ray/serve/tests/test_logs.py @@ -88,6 +88,7 @@ def __init__(self): def test_connect_serve_start_logging(serve_instance, capsys): import logging + logging.basicConfig(level=logging.INFO) @serve.deployment @@ -99,7 +100,7 @@ def __init__(self): expected_log = ( 'Connecting to existing Serve app in namespace "serve"' - '. New http options will not be applied.' + ". New http options will not be applied." ) # wait long enough for the warning to be printed