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

Add ray serve's logging context manager #16468

Merged
merged 5 commits into from
Jun 16, 2021

Conversation

jiaodong
Copy link
Member

@jiaodong jiaodong commented Jun 16, 2021

Why are these changes needed?

Current logger is passed into uvicorn's logger which logs with INFO level and a bit spammy. Therefore we can wrap the block for startup / shutdown with slightly higher level within a context manager.

Related issue number

Closes #15872

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

========= Use the following local FastAPI wrapper code to repo and verify fixes ==============

import requests
from fastapi import FastAPI

import ray
from ray import serve

serve.start()
app = FastAPI()


@serve.deployment(route_prefix="/hello")
@serve.ingress(app)
class MyFastAPIDeployment:
    @app.get("/")
    def root(self):
        return "Hello, world!"

    @app.post("/{subpath}")
    def root(self, subpath: str):
        return f"Hello from {subpath}!"

MyFastAPIDeployment.deploy()

=========== Before ==============

❯ python logging_fix_stateful.py
2021-06-15 18:16:56,958	INFO services.py:1315 -- View the Ray dashboard at http://127.0.0.1:8265
(pid=87438) 2021-06-15 18:16:58,764	INFO http_state.py:72 -- Starting HTTP proxy with name 'Rhmwjp:SERVE_CONTROLLER_ACTOR:SERVE_PROXY_ACTOR-node:192.168.86.151-0' on node 'node:192.168.86.151-0' listening on '127.0.0.1:8000'
2021-06-15 18:16:58,887	INFO api.py:713 -- Started Serve instance in namespace 'serve'.
2021-06-15 18:16:58,902	INFO api.py:415 -- Updating deployment 'MyFastAPIDeployment'.
(pid=87436) INFO:     Started server process [87436]
(pid=87438) 2021-06-15 18:16:58,975	INFO backend_state.py:773 -- Adding 1 replicas to backend 'MyFastAPIDeployment'.
(pid=87438) 2021-06-15 18:16:58,981	INFO runtime_env.py:107 -- Using preinstalled conda environment: ray
(pid=87465) 2021-06-15 18:17:01,058	INFO on.py:45 -- Waiting for application startup.
(pid=87465) 2021-06-15 18:17:01,058	INFO on.py:59 -- Application startup complete.

============ After ==============

❯ python logging_fix_stateful.py
2021-06-15 22:10:37,274	INFO services.py:1315 -- View the Ray dashboard at http://127.0.0.1:8265
(pid=96391) 2021-06-15 22:10:39,400	INFO http_state.py:72 -- Starting HTTP proxy with name 'nsXmqR:SERVE_CONTROLLER_ACTOR:SERVE_PROXY_ACTOR-node:192.168.86.151-0' on node 'node:192.168.86.151-0' listening on '127.0.0.1:8000'
2021-06-15 22:10:39,538	INFO api.py:714 -- Started Serve instance in namespace 'serve'.
(pid=96389) INFO:     Started server process [96389]
2021-06-15 22:10:39,553	INFO api.py:416 -- Updating deployment 'MyFastAPIDeployment'.
(pid=96391) 2021-06-15 22:10:39,615	INFO backend_state.py:773 -- Adding 1 replicas to backend 'MyFastAPIDeployment'.
(pid=96391) 2021-06-15 22:10:39,621	INFO runtime_env.py:107 -- Using preinstalled conda environment: ray

run formatting script scripts/format.sh
@jiaodong
Copy link
Member Author

oops latest commit removed json file for some reason -- will walk it through tomorrow, please only check the py files for now.

@simon-mo simon-mo self-assigned this Jun 16, 2021
python/ray/serve/utils.py Outdated Show resolved Hide resolved
python/ray/serve/utils.py Outdated Show resolved Hide resolved
python/ray/serve/utils.py Outdated Show resolved Hide resolved
@simon-mo simon-mo merged commit c6436ba into ray-project:master Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Serve] Lifecycle log should not be INFO
3 participants