Skip to content

Commit

Permalink
[Serve] refactor add_grpc_address helper (#48033)
Browse files Browse the repository at this point in the history
<!-- Thank you for your contribution! Please review
https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before
opening a pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?

Follow up on #47720 to move the
helper into default_impl.py

## Related issue number

<!-- For example: "Closes #1234" -->

## Checks

- [ ] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [ ] 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 added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [ ] 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 :(

---------

Signed-off-by: Gene Su <e870252314@gmail.com>
  • Loading branch information
GeneDer authored Oct 16, 2024
1 parent 8bd6a9a commit 4dfa033
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
6 changes: 6 additions & 0 deletions python/ray/serve/_private/default_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
DefaultDeploymentScheduler,
DeploymentScheduler,
)
from ray.serve._private.grpc_util import gRPCServer
from ray.serve._private.utils import get_head_node_id

# NOTE: Please read carefully before changing!
Expand All @@ -35,3 +36,8 @@ def create_deployment_scheduler(
create_placement_group_fn=create_placement_group_fn_override
or ray.util.placement_group,
)


def add_grpc_address(grpc_server: gRPCServer, server_address: str):
"""Helper function to add a address to gRPC server."""
grpc_server.add_insecure_port(server_address)
5 changes: 0 additions & 5 deletions python/ray/serve/_private/grpc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,3 @@ class DummyServicer:
def __getattr__(self, attr):
# No-op pass through. Just need this to act as the callable.
pass


def add_grpc_address(grpc_server: gRPCServer, server_address: str):
"""Helper function to add a address to gRPC server."""
grpc_server.add_insecure_port(server_address)
7 changes: 2 additions & 5 deletions python/ray/serve/_private/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@
SERVE_MULTIPLEXED_MODEL_ID,
SERVE_NAMESPACE,
)
from ray.serve._private.grpc_util import (
DummyServicer,
add_grpc_address,
create_serve_grpc_server,
)
from ray.serve._private.default_impl import add_grpc_address
from ray.serve._private.grpc_util import DummyServicer, create_serve_grpc_server
from ray.serve._private.http_util import (
MessageQueue,
convert_object_to_asgi_messages,
Expand Down
2 changes: 1 addition & 1 deletion python/ray/serve/tests/unit/test_grpc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from google.protobuf.any_pb2 import Any as AnyProto

from ray import cloudpickle
from ray.serve._private.default_impl import add_grpc_address
from ray.serve._private.grpc_util import (
DummyServicer,
add_grpc_address,
create_serve_grpc_server,
gRPCServer,
)
Expand Down

0 comments on commit 4dfa033

Please sign in to comment.