-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update module tests to use den-launched cluster (#1476)
Co-authored-by: Alexandra Belousov <[email protected]>
- Loading branch information
Showing
3 changed files
with
86 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,79 @@ | ||
from enum import Enum | ||
from typing import Union | ||
|
||
import pytest | ||
|
||
import runhouse as rh | ||
from runhouse.resources.hardware.utils import LauncherType | ||
|
||
from tests.conftest import init_args | ||
from tests.utils import setup_test_base | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def static_cpu_pwd_cluster(test_rns_folder): | ||
class computeType(str, Enum): | ||
cpu = "cpu" | ||
gpu = "gpu" | ||
|
||
|
||
def setup_static_cluster( | ||
launcher: Union[LauncherType, str] = None, | ||
compute_type: computeType = computeType.cpu, | ||
): | ||
from tests.fixtures.resource_fixtures import create_folder_path | ||
|
||
rh.constants.SSH_SKY_SECRET_NAME = ( | ||
f"{test_rns_folder}-{rh.constants.SSH_SKY_SECRET_NAME}" | ||
f"{create_folder_path()}-{rh.constants.SSH_SKY_SECRET_NAME}" | ||
) | ||
sky_cluster = rh.cluster( | ||
"aws-cpu-password", instance_type="CPU:4", provider="aws" | ||
instance_type = "CPU:4" if compute_type == computeType.cpu else "g5.xlarge" | ||
cluster = rh.cluster( | ||
f"aws-{compute_type}-password", | ||
instance_type=instance_type, | ||
provider="aws", | ||
launcher=launcher, | ||
).save() | ||
if not sky_cluster.is_up(): | ||
sky_cluster.up() | ||
if not cluster.is_up(): | ||
cluster.up() | ||
|
||
# set up password on remote | ||
sky_cluster.run_bash( | ||
cluster.run_bash( | ||
[ | ||
[ | ||
'sudo sed -i "/^[^#]*PasswordAuthentication[[:space:]]no/c\PasswordAuthentication yes" ' | ||
"/etc/ssh/sshd_config" | ||
] | ||
'sudo sed -i "/^[^#]*PasswordAuthentication[[:space:]]no/c\PasswordAuthentication yes" /etc/ssh/sshd_config' | ||
] | ||
) | ||
sky_cluster.run_bash(["sudo /etc/init.d/ssh force-reload"]) | ||
sky_cluster.run_bash(["sudo /etc/init.d/ssh restart"]) | ||
sky_cluster.run_bash( | ||
cluster.run_bash(["sudo /etc/init.d/ssh force-reload"]) | ||
cluster.run_bash(["sudo /etc/init.d/ssh restart"]) | ||
cluster.run_bash( | ||
["(echo 'cluster-pass' && echo 'cluster-pass') | sudo passwd ubuntu"] | ||
) | ||
sky_cluster.run_bash( | ||
["pip uninstall skypilot runhouse -y", "pip install pytest"] | ||
) | ||
sky_cluster.run_bash(["rm -rf runhouse/"]) | ||
cluster.run_bash(["pip uninstall skypilot runhouse -y", "pip install pytest"]) | ||
cluster.run_bash(["rm -rf runhouse/"]) | ||
|
||
# instantiate byo cluster with password | ||
ssh_creds = { | ||
"ssh_user": "ubuntu", | ||
"ssh_private_key": "~/.ssh/sky-key", | ||
"password": "cluster-pass", | ||
} | ||
args = dict( | ||
name="static-cpu-password", host=[sky_cluster.head_ip], ssh_creds=ssh_creds | ||
) | ||
args = dict(name="static-cpu-password", host=[cluster.head_ip], ssh_creds=ssh_creds) | ||
c = rh.cluster(**args).save() | ||
c.restart_server(resync_rh=True) | ||
init_args[id(c)] = args | ||
|
||
setup_test_base(c) | ||
|
||
return c | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def static_cpu_pwd_cluster(): | ||
return setup_static_cluster() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def static_cpu_pwd_cluster_den_launcher(): | ||
return setup_static_cluster(launcher=LauncherType.DEN) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def static_gpu_pwd_cluster_den_launcher(): | ||
return setup_static_cluster(launcher=LauncherType.DEN, compute_type=computeType.gpu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters