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

Fix release test -- client remote put #15325

Merged
merged 5 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 20 additions & 9 deletions python/ray/_private/ray_client_microbenchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from ray.util.client.ray_client_helpers import ray_start_client_server

from ray._private.ray_microbenchmark_helpers import timeit
from ray._private.ray_microbenchmark_helpers import ray_setup_and_teardown


def benchmark_get_calls(ray):
Expand Down Expand Up @@ -69,14 +68,26 @@ def actor_concurrent():


def main():
system_config = {"put_small_object_in_memory_store": True}
with ray_setup_and_teardown(
logging_level=logging.WARNING, _system_config=system_config):
for name, obj in inspect.getmembers(sys.modules[__name__]):
if not name.startswith("benchmark_"):
continue
with ray_start_client_server() as ray:
obj(ray)
ray_config = {
"_system_config": {
"put_small_object_in_memory_store": True
},
"logging_level": logging.WARNING
}

def ray_connect_handler(job_config=None):
import ray as real_ray
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should import ray just work? I feel disable_client_hook will take care of everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if you don't have the import in here and only the disable_client_hook, the behavior is actually unexpected (and fails).

So it's important to have some form of import in here, but I felt that real_ray was more readable and would prevent scoping problems

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you misunderstood me.
I mean we don't necessarily rename it to real_ray since it doesn't quite make sense here.

If you don't call with disable_client_hook, it's actually not real_ray, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK i tried a small fix here!

from ray._private.client_mode_hook import disable_client_hook
with disable_client_hook():
if not real_ray.is_initialized():
real_ray.init(**ray_config)
richardliaw marked this conversation as resolved.
Show resolved Hide resolved

for name, obj in inspect.getmembers(sys.modules[__name__]):
if not name.startswith("benchmark_"):
continue
with ray_start_client_server(
ray_connect_handler=ray_connect_handler) as ray:
obj(ray)


if __name__ == "__main__":
Expand Down
11 changes: 7 additions & 4 deletions python/ray/util/client/ray_client_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@


@contextmanager
def ray_start_client_server(metadata=None):
with ray_start_client_server_pair(metadata=metadata) as pair:
def ray_start_client_server(metadata=None, ray_connect_handler=None):
with ray_start_client_server_pair(
metadata=metadata,
ray_connect_handler=ray_connect_handler) as pair:
client, server = pair
yield client


@contextmanager
def ray_start_client_server_pair(metadata=None):
def ray_start_client_server_pair(metadata=None, ray_connect_handler=None):
ray._inside_client_test = True
server = ray_client_server.serve("localhost:50051")
server = ray_client_server.serve(
"localhost:50051", ray_connect_handler=ray_connect_handler)
ray.connect("localhost:50051", metadata=metadata)
try:
yield ray, server
Expand Down
5 changes: 2 additions & 3 deletions python/ray/util/client/server/dataservicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def Datapath(self, request_iterator, context):
finally:
logger.debug(f"Lost data connection from client {client_id}")
self.basic_service.release_all(client_id)
richardliaw marked this conversation as resolved.
Show resolved Hide resolved

with self.clients_lock:
if accepted_connection:
# Could fail before client accounting happens
Expand All @@ -91,8 +90,8 @@ def Datapath(self, request_iterator, context):

# It's important to keep the Ray shutdown
# within this locked context or else Ray could hang.
with disable_client_hook():
if self.num_clients == 0:
if self.num_clients == 0:
with disable_client_hook():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we change swap this?

richardliaw marked this conversation as resolved.
Show resolved Hide resolved
logger.debug("Shutting down ray.")
ray.shutdown()

Expand Down