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-#2386: add new location for import ray functions #2387

Merged
merged 1 commit into from
Nov 10, 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
41 changes: 20 additions & 21 deletions modin/experimental/cloud/rayscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,23 @@
import subprocess

import yaml
from ray.autoscaler.commands import (
create_or_update_cluster,
teardown_cluster,
get_head_node_ip,
_bootstrap_config,
)

try:
# for ray>=1.0.1
from ray.autoscaler.sdk import (
create_or_update_cluster,
teardown_cluster,
get_head_node_ip,
bootstrap_config,
)
except ModuleNotFoundError:
# for ray==1.0.0
from ray.autoscaler.commands import (
create_or_update_cluster,
teardown_cluster,
get_head_node_ip,
_bootstrap_config as bootstrap_config,
)

from .base import (
CannotSpawnCluster,
Expand Down Expand Up @@ -140,7 +151,7 @@ def __make_config(self):
res = self._update_conda_requirements(config["setup_commands"][0])
config["setup_commands"][0] = res

return _bootstrap_config(config)
return bootstrap_config(config)

def _conda_requirements(self):
import shlex
Expand Down Expand Up @@ -197,15 +208,9 @@ def __do_spawn(self):
try:
create_or_update_cluster(
self.config_file,
override_min_workers=None,
override_max_workers=None,
no_restart=False,
restart_only=False,
yes=True,
override_cluster_name=None,
no_config_cache=False,
redirect_command_output=False,
use_login_shells=True,
)
# need to re-load the config, as create_or_update_cluster() modifies it
with open(self.config_file) as inp:
Expand All @@ -220,13 +225,7 @@ def __do_spawn(self):

def __do_destroy(self):
try:
teardown_cluster(
self.config_file,
yes=True,
workers_only=False,
override_cluster_name=None,
keep_min_workers=0,
)
teardown_cluster(self.config_file)
self.ready = False
self.config = None
except BaseException as ex:
Expand All @@ -244,7 +243,7 @@ def _get_connection_details(self) -> ConnectionDetails:
return ConnectionDetails(
user_name=self.config["auth"]["ssh_user"],
key_file=self.config["auth"]["ssh_private_key"],
address=get_head_node_ip(self.config_file, override_cluster_name=None),
address=get_head_node_ip(self.config_file),
)

def _get_main_python(self) -> str:
Expand Down
14 changes: 7 additions & 7 deletions modin/experimental/cloud/test/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
import pytest
from collections import namedtuple
from inspect import signature
from modin.experimental.cloud.rayscale import RayCluster
from modin.experimental.cloud.cluster import Provider
from ray.autoscaler.commands import (
from modin.experimental.cloud.rayscale import (
RayCluster,
create_or_update_cluster,
teardown_cluster,
get_head_node_ip,
_bootstrap_config,
bootstrap_config,
)
from modin.experimental.cloud.cluster import Provider


@pytest.fixture
def make_bootstrap_config_mock():
def bootstrap_config_mock(config, *args, **kwargs):
signature(_bootstrap_config).bind(config, *args, **kwargs)
signature(bootstrap_config).bind(config, *args, **kwargs)
config["auth"]["ssh_user"] = "modin"
config["auth"]["ssh_private_key"] = "X" * 20
return config
Expand Down Expand Up @@ -59,7 +59,7 @@ def make_create_or_update_cluster_mock():
def make_ray_cluster(make_bootstrap_config_mock):
def ray_cluster(conda_packages=None):
with mock.patch(
"modin.experimental.cloud.rayscale._bootstrap_config",
"modin.experimental.cloud.rayscale.bootstrap_config",
make_bootstrap_config_mock,
):
ray_cluster = RayCluster(
Expand All @@ -71,7 +71,7 @@ def ray_cluster(conda_packages=None):
return ray_cluster


def test__bootstrap_config(make_ray_cluster):
def test_bootstrap_config(make_ray_cluster):
make_ray_cluster()


Expand Down