mirror of
https://github.com/vale981/ray
synced 2025-03-08 19:41:38 -05:00
This reverts commit 39aa01fc2c
.
This commit is contained in:
parent
ecb94b3fe9
commit
d8f8583e80
8 changed files with 6 additions and 39 deletions
|
@ -651,7 +651,6 @@ def start(
|
||||||
http_port: int = DEFAULT_HTTP_PORT,
|
http_port: int = DEFAULT_HTTP_PORT,
|
||||||
http_middlewares: List[Any] = [],
|
http_middlewares: List[Any] = [],
|
||||||
http_options: Optional[Union[dict, HTTPOptions]] = None,
|
http_options: Optional[Union[dict, HTTPOptions]] = None,
|
||||||
dedicated_cpu: bool = False,
|
|
||||||
) -> Client:
|
) -> Client:
|
||||||
"""Initialize a serve instance.
|
"""Initialize a serve instance.
|
||||||
|
|
||||||
|
@ -676,7 +675,7 @@ def start(
|
||||||
this to "0.0.0.0".
|
this to "0.0.0.0".
|
||||||
- port(int): Port for HTTP server. Defaults to 8000.
|
- port(int): Port for HTTP server. Defaults to 8000.
|
||||||
- middlewares(list): A list of Starlette middlewares that will be
|
- middlewares(list): A list of Starlette middlewares that will be
|
||||||
applied to the HTTP servers in the cluster. Defaults to [].
|
applied to the HTTP servers in the cluster.
|
||||||
- location(str, serve.config.DeploymentMode): The deployment
|
- location(str, serve.config.DeploymentMode): The deployment
|
||||||
location of HTTP servers:
|
location of HTTP servers:
|
||||||
|
|
||||||
|
@ -685,10 +684,6 @@ def start(
|
||||||
on. This is the default.
|
on. This is the default.
|
||||||
- "EveryNode": start one HTTP server per node.
|
- "EveryNode": start one HTTP server per node.
|
||||||
- "NoServer" or None: disable HTTP server.
|
- "NoServer" or None: disable HTTP server.
|
||||||
- num_cpus (int): The number of CPU cores to reserve for each
|
|
||||||
internal Serve HTTP proxy actor. Defaults to 0.
|
|
||||||
dedicated_cpu (bool): Whether to reserve a CPU core for the internal
|
|
||||||
Serve controller actor. Defaults to False.
|
|
||||||
"""
|
"""
|
||||||
if ((http_host != DEFAULT_HTTP_HOST) or (http_port != DEFAULT_HTTP_PORT)
|
if ((http_host != DEFAULT_HTTP_HOST) or (http_port != DEFAULT_HTTP_PORT)
|
||||||
or (len(http_middlewares) != 0)):
|
or (len(http_middlewares) != 0)):
|
||||||
|
@ -733,7 +728,6 @@ def start(
|
||||||
host=http_host, port=http_port, middlewares=http_middlewares)
|
host=http_host, port=http_port, middlewares=http_middlewares)
|
||||||
|
|
||||||
controller = ServeController.options(
|
controller = ServeController.options(
|
||||||
num_cpus=(1 if dedicated_cpu else 0),
|
|
||||||
name=controller_name,
|
name=controller_name,
|
||||||
lifetime="detached" if detached else None,
|
lifetime="detached" if detached else None,
|
||||||
max_restarts=-1,
|
max_restarts=-1,
|
||||||
|
|
|
@ -244,7 +244,6 @@ class HTTPOptions(pydantic.BaseModel):
|
||||||
port: int = DEFAULT_HTTP_PORT
|
port: int = DEFAULT_HTTP_PORT
|
||||||
middlewares: List[Any] = []
|
middlewares: List[Any] = []
|
||||||
location: Optional[DeploymentMode] = DeploymentMode.HeadOnly
|
location: Optional[DeploymentMode] = DeploymentMode.HeadOnly
|
||||||
num_cpus: int = 0
|
|
||||||
|
|
||||||
@validator("location", always=True)
|
@validator("location", always=True)
|
||||||
def location_backfill_no_server(cls, v, values):
|
def location_backfill_no_server(cls, v, values):
|
||||||
|
|
|
@ -38,7 +38,7 @@ CHECKPOINT_KEY = "serve-controller-checkpoint"
|
||||||
CONTROL_LOOP_PERIOD_S = 0.1
|
CONTROL_LOOP_PERIOD_S = 0.1
|
||||||
|
|
||||||
|
|
||||||
@ray.remote(num_cpus=0)
|
@ray.remote
|
||||||
class ServeController:
|
class ServeController:
|
||||||
"""Responsible for managing the state of the serving system.
|
"""Responsible for managing the state of the serving system.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import ray
|
||||||
from ray import serve
|
from ray import serve
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
ray.init()
|
ray.init(num_cpus=4)
|
||||||
serve.start()
|
serve.start()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import ray
|
||||||
from ray import serve
|
from ray import serve
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
ray.init()
|
ray.init(num_cpus=4)
|
||||||
serve.start()
|
serve.start()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ class HTTPProxy:
|
||||||
await self.router(scope, receive, send)
|
await self.router(scope, receive, send)
|
||||||
|
|
||||||
|
|
||||||
@ray.remote(num_cpus=0)
|
@ray.remote
|
||||||
class HTTPProxyActor:
|
class HTTPProxyActor:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
host: str,
|
host: str,
|
||||||
|
|
|
@ -69,7 +69,6 @@ class HTTPState:
|
||||||
name, node_id, self._config.host,
|
name, node_id, self._config.host,
|
||||||
self._config.port))
|
self._config.port))
|
||||||
proxy = HTTPProxyActor.options(
|
proxy = HTTPProxyActor.options(
|
||||||
num_cpus=self._config.num_cpus,
|
|
||||||
name=name,
|
name=name,
|
||||||
lifetime="detached" if self._detached else None,
|
lifetime="detached" if self._detached else None,
|
||||||
max_concurrency=ASYNC_CONCURRENCY,
|
max_concurrency=ASYNC_CONCURRENCY,
|
||||||
|
|
|
@ -15,7 +15,6 @@ from ray.serve.constants import SERVE_PROXY_NAME
|
||||||
from ray.serve.exceptions import RayServeException
|
from ray.serve.exceptions import RayServeException
|
||||||
from ray.serve.utils import (block_until_http_ready, get_all_node_ids,
|
from ray.serve.utils import (block_until_http_ready, get_all_node_ids,
|
||||||
format_actor_name)
|
format_actor_name)
|
||||||
from ray.serve.config import HTTPOptions
|
|
||||||
from ray.test_utils import wait_for_condition
|
from ray.test_utils import wait_for_condition
|
||||||
from ray._private.services import new_port
|
from ray._private.services import new_port
|
||||||
|
|
||||||
|
@ -122,30 +121,6 @@ def test_connect(detached, ray_shutdown):
|
||||||
assert "backend-ception" in serve.list_backends().keys()
|
assert "backend-ception" in serve.list_backends().keys()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows")
|
|
||||||
@pytest.mark.parametrize("controller_cpu", [True, False])
|
|
||||||
@pytest.mark.parametrize("num_proxy_cpus", [0, 1, 2])
|
|
||||||
def test_dedicated_cpu(controller_cpu, num_proxy_cpus, ray_cluster):
|
|
||||||
cluster = ray_cluster
|
|
||||||
num_cluster_cpus = 8
|
|
||||||
head_node = cluster.add_node(num_cpus=num_cluster_cpus)
|
|
||||||
|
|
||||||
ray.init(head_node.address)
|
|
||||||
wait_for_condition(
|
|
||||||
lambda: ray.cluster_resources().get("CPU") == num_cluster_cpus)
|
|
||||||
|
|
||||||
num_cpus_used = int(controller_cpu) + num_proxy_cpus
|
|
||||||
|
|
||||||
serve.start(
|
|
||||||
dedicated_cpu=controller_cpu,
|
|
||||||
http_options=HTTPOptions(num_cpus=num_proxy_cpus))
|
|
||||||
available_cpus = num_cluster_cpus - num_cpus_used
|
|
||||||
wait_for_condition(
|
|
||||||
lambda: (ray.available_resources().get("CPU") == available_cpus))
|
|
||||||
serve.shutdown()
|
|
||||||
ray.shutdown()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
not hasattr(socket, "SO_REUSEPORT"),
|
not hasattr(socket, "SO_REUSEPORT"),
|
||||||
reason=("Port sharing only works on newer verion of Linux. "
|
reason=("Port sharing only works on newer verion of Linux. "
|
||||||
|
@ -329,7 +304,7 @@ def test_http_head_only(ray_cluster):
|
||||||
r["CPU"]
|
r["CPU"]
|
||||||
for r in ray.state.state._available_resources_per_node().values()
|
for r in ray.state.state._available_resources_per_node().values()
|
||||||
}
|
}
|
||||||
assert cpu_per_nodes == {4, 4}
|
assert cpu_per_nodes == {2, 4}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Reference in a new issue