forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Serve] Add logging config doc (ray-project#41708)
Signed-off-by: Sihan Wang <[email protected]>
- Loading branch information
1 parent
fe8e1c5
commit a5bb051
Showing
6 changed files
with
201 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import requests | ||
import logging | ||
from ray import serve | ||
from ray.serve.schema import LoggingConfig | ||
|
||
# __json_start__ | ||
|
||
|
||
@serve.deployment(logging_config=LoggingConfig(encoding="JSON")) | ||
class Model: | ||
def __call__(self) -> int: | ||
return "hello world" | ||
|
||
|
||
# __json_end__ | ||
|
||
serve.run(Model.bind()) | ||
|
||
resp = requests.get("http:https://localhost:8000/") | ||
|
||
|
||
# __level_start__ | ||
|
||
|
||
@serve.deployment(logging_config=LoggingConfig(log_level="DEBUG")) | ||
class Model: | ||
def __call__(self) -> int: | ||
logger = logging.getLogger("ray.serve") | ||
logger.debug("This debug message is from the router.") | ||
return "hello world" | ||
|
||
|
||
# __level_end__ | ||
|
||
serve.run(Model.bind()) | ||
|
||
resp = requests.get("http:https://localhost:8000/") | ||
|
||
|
||
# __logs_dir_start__ | ||
@serve.deployment(logging_config=LoggingConfig(logs_dir="/my_dirs")) | ||
class Model: | ||
def __call__(self) -> int: | ||
return "hello world" | ||
|
||
|
||
# __logs_dir_end__ | ||
|
||
|
||
# __enable_access_log_start__ | ||
@serve.deployment(logging_config={"enable_access_log": False}) | ||
class Model: | ||
def __call__(self) -> int: | ||
logger = logging.getLogger("ray.serve") | ||
logger.info("hello world") | ||
return | ||
|
||
|
||
# __enable_access_log_end__ | ||
|
||
serve.run(Model.bind()) | ||
|
||
resp = requests.get("http:https://localhost:8000/") | ||
|
||
|
||
# __application_and_deployment_start__ | ||
@serve.deployment | ||
class Router: | ||
def __init__(self, handle): | ||
self.handle = handle | ||
|
||
async def __call__(self): | ||
logger = logging.getLogger("ray.serve") | ||
logger.debug("This debug message is from the router.") | ||
return await self.handle.remote() | ||
|
||
|
||
@serve.deployment | ||
class Model: | ||
def __call__(self) -> int: | ||
logger = logging.getLogger("ray.serve") | ||
logger.debug("This debug message is from the model.") | ||
return "hello world" | ||
|
||
|
||
serve.run(Router.bind(Model.bind()), logging_config={"log_level": "DEBUG"}) | ||
resp = requests.get("http:https://localhost:8000/") | ||
# __application_and_deployment_end__ | ||
|
||
# __configure_serve_component_start__ | ||
serve.start(logging_config={"log_level": "DEBUG"}) | ||
# __configure_serve_component_end__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters