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 ray_init_kwargs from serve.init #8747

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions python/ray/serve/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from functools import wraps

from multiprocessing import cpu_count

import ray
from ray.serve.constants import (DEFAULT_HTTP_HOST, DEFAULT_HTTP_PORT,
SERVE_MASTER_NAME, HTTP_PROXY_TIMEOUT)
Expand Down Expand Up @@ -63,28 +61,21 @@ def __call__(self, *, python_arg=None):
def init(cluster_name=None,
http_host=DEFAULT_HTTP_HOST,
http_port=DEFAULT_HTTP_PORT,
ray_init_kwargs={
"object_store_memory": int(1e8),
"num_cpus": max(cpu_count(), 8)
},
metric_exporter=InMemoryExporter):
"""Initialize a serve cluster.
"""Initialize or connect to a serve cluster.

If serve cluster has already initialized, this function will just return.
If serve cluster is already initialized, this function will just return.

Calling `ray.init` before `serve.init` is optional. When there is not a ray
cluster initialized, serve will call `ray.init` with `object_store_memory`
requirement.
If `ray.init` has not been called in this process, it will be called with
no arguments. To specify kwargs to `ray.init`, it should be called
separately before calling `serve.init`.

Args:
cluster_name (str): A unique name for this serve cluster. This allows
multiple serve clusters to run on the same ray cluster. Must be
specified in all subsequent serve.init() calls.
http_host (str): Host for HTTP server. Default to "0.0.0.0".
http_port (int): Port for HTTP server. Default to 8000.
ray_init_kwargs (dict): Argument passed to ray.init, if there is no ray
connection. Default to {"object_store_memory": int(1e8)} for
performance stability reason
metric_exporter(ExporterInterface): The class aggregates metrics from
all RayServe actors and optionally export them to external
services. RayServe has two options built in: InMemoryExporter and
Expand All @@ -95,7 +86,7 @@ def init(cluster_name=None,

# Initialize ray if needed.
if not ray.is_initialized():
ray.init(**ray_init_kwargs)
ray.init()

# Try to get serve master actor if it exists
global master_actor
Expand Down
4 changes: 3 additions & 1 deletion python/ray/serve/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

import ray
from ray import serve
from ray.serve.utils import retry_actor_failures

Expand All @@ -11,7 +12,8 @@

@pytest.fixture(scope="session")
def _shared_serve_instance():
serve.init(ray_init_kwargs={"num_cpus": 36})
ray.init(num_cpus=36)
serve.init()
yield


Expand Down