[serve] Don't create placement group for deployment with no resources (#20471)

This commit is contained in:
iasoon 2021-11-24 04:27:43 +01:00 committed by GitHub
parent 08655ab812
commit 186c16c50e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View file

@ -167,12 +167,17 @@ class ActorReplicaWrapper:
"""
Start a new actor for current DeploymentReplica instance.
"""
self._actor_resources = deployment_info.replica_config.resource_dict
self._max_concurrent_queries = (
deployment_info.deployment_config.max_concurrent_queries)
self._graceful_shutdown_timeout_s = (
deployment_info.deployment_config.graceful_shutdown_timeout_s)
if USE_PLACEMENT_GROUP:
self._actor_resources = deployment_info.replica_config.resource_dict
# it is currently not possiible to create a placement group
# with no resources (https://github.com/ray-project/ray/issues/20401)
has_resources_assigned = all(
(r > 0 for r in self._actor_resources.values()))
if USE_PLACEMENT_GROUP and has_resources_assigned:
self._placement_group = self.create_placement_group(
self._placement_group_name, self._actor_resources)

View file

@ -1098,6 +1098,17 @@ def test_deploy_change_route_prefix(serve_instance):
wait_for_condition(check_switched)
@pytest.mark.timeout(10, method="thread")
def test_deploy_empty_bundle(serve_instance):
@serve.deployment(ray_actor_options={"num_cpus": 0})
class D:
def hello(self, _):
return "hello"
# This should succesfully terminate within the provided time-frame.
D.deploy()
if __name__ == "__main__":
import sys
sys.exit(pytest.main(["-v", "-s", __file__]))