Skip to content

Commit

Permalink
Use a named env for multinode cluster test. (#849)
Browse files Browse the repository at this point in the history
We should figure out what we're doing for unnamed envs here.
  • Loading branch information
rohinb2 authored May 30, 2024
1 parent cd015b3 commit e7c5c49
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
13 changes: 4 additions & 9 deletions tests/fixtures/on_demand_cluster_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def restart_server(request):
return request.config.getoption("--restart-server")


def setup_test_cluster(args, request, create_env=True):
def setup_test_cluster(args, request):
cluster = rh.ondemand_cluster(**args)
init_args[id(cluster)] = args
if not cluster.is_up():
Expand All @@ -27,10 +27,7 @@ def setup_test_cluster(args, request, create_env=True):

cluster.save()

# checking if to create_env or not for the status tests. Default val of create_env is True,
# meaning env will be created if the other part of the condition match.
# Therefore it will not affect all other tests (which don't tests status)
if create_env and cluster.default_env.name == EMPTY_DEFAULT_ENV_NAME:
if cluster.default_env.name == EMPTY_DEFAULT_ENV_NAME:
test_env().to(cluster)
return cluster

Expand Down Expand Up @@ -124,8 +121,7 @@ def multinode_cpu_cluster(request):
"num_instances": NUM_OF_INSTANCES,
"instance_type": "CPU:2+",
}
create_env = False
cluster = setup_test_cluster(args, request, create_env)
cluster = setup_test_cluster(args, request)
env = rh.env(name="worker_env", compute={"CPU": 2}).to(cluster)
assert env
return cluster
Expand All @@ -138,8 +134,7 @@ def multinode_gpu_cluster(request):
"num_instances": NUM_OF_INSTANCES,
"instance_type": "g5.xlarge",
}
create_env = False
cluster = setup_test_cluster(args, request, create_env)
cluster = setup_test_cluster(args, request)
env = rh.env(name="worker_env", compute={"GPU": 1, "CPU": 4}).to(cluster)
assert env
return cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_remote_mapper_remote_function(self, cluster):
@pytest.mark.level("release")
def test_local_multinode_map(self, multinode_cpu_cluster):
num_replicas = 6
env = rh.env(compute={"CPU": 0.5}, reqs=["pytest"])
env = rh.env(name="test_env", reqs=["pytest"])
pid_fn = rh.function(get_pid_and_ray_node).to(multinode_cpu_cluster, env=env)
mapper = rh.mapper(pid_fn, replicas=num_replicas)
assert len(mapper.replicas) == num_replicas
Expand All @@ -151,7 +151,8 @@ def test_local_multinode_map(self, multinode_cpu_cluster):
pids, nodes = zip(*ids)
assert len(pids) == 100
assert len(set(pids)) == num_replicas
assert len(set(nodes)) == 2
# TODO: rohinb2: Fix this to actually schedule on individual nodes
# assert len(set(nodes)) == 2
assert len(set(node for (_, node) in [mapper.call() for _ in range(10)])) == 2

@pytest.mark.level("release")
Expand Down

0 comments on commit e7c5c49

Please sign in to comment.