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] Remove dashboard's dependency on Serve #23389

Merged
merged 13 commits into from
Mar 22, 2022
Prev Previous commit
Next Next commit
Delay serve imports
  • Loading branch information
shrekris-anyscale committed Mar 21, 2022
commit 2846b7698ee251d9382ec44a68c7d2d2c9c64e69
25 changes: 16 additions & 9 deletions dashboard/modules/serve/serve_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
import ray.dashboard.utils as dashboard_utils
import ray.dashboard.optional_utils as optional_utils

from ray import serve
from ray.serve.api import (
Application,
get_deployment_statuses,
internal_get_global_client,
serve_application_status_to_schema,
)

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

Expand All @@ -26,7 +18,9 @@ def __init__(self, dashboard_head):
@routes.get("/api/serve/deployments/")
@optional_utils.init_ray_and_catch_exceptions(connect_to_serve=True)
async def get_all_deployments(self, req: Request) -> Response:
app = Application(list(serve.list_deployments().values()))
from ray.serve.api import Application, list_deployments

app = Application(list(list_deployments().values()))
return Response(
text=json.dumps(app.to_dict()),
content_type="application/json",
Expand All @@ -35,6 +29,11 @@ async def get_all_deployments(self, req: Request) -> Response:
@routes.get("/api/serve/deployments/status")
@optional_utils.init_ray_and_catch_exceptions(connect_to_serve=True)
async def get_all_deployment_statuses(self, req: Request) -> Response:
from ray.serve.api import (
serve_application_status_to_schema,
get_deployment_statuses,
)

serve_application_status_schema = serve_application_status_to_schema(
get_deployment_statuses()
)
Expand All @@ -46,12 +45,20 @@ async def get_all_deployment_statuses(self, req: Request) -> Response:
@routes.delete("/api/serve/deployments/")
@optional_utils.init_ray_and_catch_exceptions(connect_to_serve=True)
async def delete_serve_application(self, req: Request) -> Response:
from ray import serve

serve.shutdown()
return Response()

@routes.put("/api/serve/deployments/")
@optional_utils.init_ray_and_catch_exceptions(connect_to_serve=True)
async def put_all_deployments(self, req: Request) -> Response:
from ray import serve
from ray.serve.api import (
Application,
internal_get_global_client,
)

app = Application.from_dict(await req.json())
serve.run(app, _blocking=False)

Expand Down