Skip to content

Commit 0bfe7e0

Browse files
committed
Remove usage of .env in tests
1 parent 92b337c commit 0bfe7e0

19 files changed

+170
-249
lines changed

runhouse/resources/hardware/cluster.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -813,19 +813,19 @@ def put_resource(
813813
process (str, optional): Process of the object store to put the object in. (Default: ``None``)
814814
"""
815815
# Logic to get env_name from different ways env can be provided
816-
env_name = process or (
816+
process = process or (
817817
resource.process if hasattr(resource, "process") else DEFAULT_PROCESS_NAME
818818
)
819819

820820
state = state or {}
821821
if self.on_this_cluster():
822822
data = (resource.config(condensed=False), state, dryrun)
823-
return obj_store.put_resource(serialized_data=data, process=env_name)
823+
return obj_store.put_resource(serialized_data=data, process=process)
824824
return self.call_client_method(
825825
"put_resource",
826826
resource,
827827
state=state or {},
828-
process=env_name,
828+
process=process,
829829
dryrun=dryrun,
830830
)
831831

tests/constants.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
os.getenv("RH_AUTOSTOP_INTERVAL") or TESTING_AUTOSTOP_INTERVAL
1313
),
1414
}
15+
16+
TEST_REQS = ["pytest", "httpx", "pytest_asyncio", "pandas", "numpy<=1.26.4"]

tests/fixtures/docker_cluster_fixtures.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from tests.conftest import init_args
1919

2020
from tests.constants import TEST_ENV_VARS
21-
from tests.utils import friend_account, test_env
21+
from tests.utils import friend_account, setup_test_base
2222

2323
SSH_USER = "rh-docker-user"
2424
BASE_LOCAL_SSH_PORT = 32320
@@ -278,7 +278,7 @@ def set_up_local_cluster(
278278
rh_cluster.restart_server(resync_rh=True)
279279

280280
if not rh_cluster.image:
281-
test_env(logged_in=logged_in).to(rh_cluster)
281+
setup_test_base(rh_cluster, logged_in=logged_in)
282282

283283
def cleanup():
284284
docker_client.containers.get(container_name).stop()
@@ -353,7 +353,7 @@ def docker_cluster_pk_ssh(request, test_org_rns_folder):
353353
"""This basic cluster fixture is set up with:
354354
- Public key authentication
355355
- Caddy set up on startup to forward Runhouse HTTP server to port 443
356-
- Default env with Ray 2.30.0
356+
- Default image with Ray 2.30.0
357357
"""
358358
# From pytest config
359359
detached = request.config.getoption("--detached")
@@ -457,7 +457,7 @@ def docker_cluster_pk_http_exposed(request, test_rns_folder):
457457
- Public key authentication
458458
- Den auth disabled (to mimic VPC)
459459
- Caddy set up on startup to forward Runhouse HTTP Server to port 80
460-
- Default conda_env with Python 3.11 and Ray 2.30.0
460+
- Default conda image with Python 3.11 and Ray 2.30.0
461461
"""
462462
# From pytest config
463463
detached = request.config.getoption("--detached")

tests/fixtures/on_demand_cluster_fixtures.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from runhouse.resources.images.image import Image
99
from tests.conftest import init_args
1010

11-
from tests.constants import TEST_ENV_VARS
12-
from tests.utils import test_env
11+
from tests.constants import TEST_ENV_VARS, TEST_REQS
12+
from tests.utils import setup_test_base
1313

1414
NUM_OF_NODES = 2
1515

@@ -19,7 +19,7 @@ def restart_server(request):
1919
return request.config.getoption("--restart-server")
2020

2121

22-
def setup_test_cluster(args, request, create_env=False):
22+
def setup_test_cluster(args, request, setup_base=False):
2323
cluster = rh.ondemand_cluster(**args)
2424
init_args[id(cluster)] = args
2525
cluster.up_if_not()
@@ -28,8 +28,8 @@ def setup_test_cluster(args, request, create_env=False):
2828

2929
cluster.save()
3030

31-
if create_env or not cluster.image:
32-
test_env().to(cluster)
31+
if setup_base or not cluster.image:
32+
setup_test_base(cluster)
3333
return cluster
3434

3535

@@ -52,7 +52,7 @@ def ondemand_cluster(request):
5252
@pytest.fixture(scope="session")
5353
def ondemand_aws_docker_cluster(request):
5454
"""
55-
Note: Also used to test docker and default env with alternate Ray version.
55+
Note: Also used to test docker and default process with alternate Ray version.
5656
"""
5757
image = (
5858
Image(name="default_image")
@@ -67,7 +67,7 @@ def ondemand_aws_docker_cluster(request):
6767
"image": image,
6868
"sky_kwargs": {"launch": {"retry_until_up": True}},
6969
}
70-
cluster = setup_test_cluster(args, request, create_env=True)
70+
cluster = setup_test_cluster(args, request, setup_base=True)
7171
return cluster
7272

7373

@@ -99,7 +99,7 @@ def ondemand_gcp_cluster(request):
9999
conda_env_name="base_env",
100100
conda_yaml={"dependencies": ["python=3.11"], "name": "base_env"},
101101
)
102-
.install_packages(test_env().reqs + ["ray==2.30.0"], conda_env_name="base_env")
102+
.install_packages(TEST_REQS + ["ray==2.30.0"], conda_env_name="base_env")
103103
.set_env_vars(env_vars=TEST_ENV_VARS)
104104
)
105105
args = {
@@ -203,7 +203,7 @@ def multinode_cpu_docker_conda_cluster(request):
203203
conda_env_name="base_env",
204204
conda_yaml={"dependencies": ["python=3.11"], "name": "base_env"},
205205
)
206-
.install_packages(test_env().reqs + ["ray==2.30.0"], conda_env_name="base_env")
206+
.install_packages(TEST_REQS + ["ray==2.30.0"], conda_env_name="base_env")
207207
)
208208
args = {
209209
"name": "rh-cpu-multinode",

tests/fixtures/static_cluster_fixtures.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import runhouse as rh
44

55
from tests.conftest import init_args
6-
from tests.utils import test_env
6+
from tests.utils import setup_test_base
77

88

99
@pytest.fixture(scope="session")
@@ -44,6 +44,6 @@ def static_cpu_pwd_cluster():
4444
c.restart_server(resync_rh=True)
4545
init_args[id(c)] = args
4646

47-
test_env().to(c)
47+
setup_test_base(c)
4848

4949
return c

tests/test_obj_store.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ def test_pinning_and_arg_replacement(cluster):
151151
assert pin_fn("put_pin") == "Found in obj store!"
152152

153153

154-
def test_put_resource(cluster, test_env):
155-
test_env.name = "~/test_env"
156-
cluster.put_resource(test_env)
157-
assert cluster.call("test_env", "config", stream_logs=True) == test_env.config()
158-
assert cluster.get("test_env").config() == test_env.config()
154+
def test_put_resource(cluster):
155+
resource = rh.function(fn=do_printing_and_logging, system=cluster)
156+
cluster.put_resource(resource)
157+
assert cluster.call(resource.name, "config", stream_logs=True) == resource.config()
158+
assert cluster.get(resource.name).config() == resource.config()
159159

160160

161161
def serialization_helper_1():

tests/test_resources/test_clusters/cluster_tests.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ def test_byo_proxy(static_cpu_pwd_cluster, local_folder):
132132
assert status == 0
133133
assert stdout == "hi\n"
134134

135-
summer_func = rh.function(summer, env=rh.env(working_dir="local:./")).to(
136-
static_cpu_pwd_cluster
137-
)
135+
summer_func = rh.function(summer).to(static_cpu_pwd_cluster)
138136
assert summer_func(1, 2) == 3
139137

140138
static_cpu_pwd_cluster.put("test_obj", list(range(10)))

0 commit comments

Comments
 (0)