Skip to content

Commit e5a35ad

Browse files
Add test cases for external ray cluster
1 parent b8941a3 commit e5a35ad

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/utils/conftest.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
import pytest
2+
import ray
3+
from ray.cluster_utils import Cluster
24

35
from pydvl.utils.config import ParallelConfig
46

57

6-
@pytest.fixture(scope="session", params=["sequential", "ray"])
8+
@pytest.fixture(scope="session", params=["sequential", "ray-local", "ray-external"])
79
def parallel_config(request):
8-
return ParallelConfig(backend=request.param)
10+
if request.param == "sequential":
11+
yield ParallelConfig(backend=request.param)
12+
elif request.param == "ray-local":
13+
yield ParallelConfig(backend="ray")
14+
ray.shutdown()
15+
elif request.param == "ray-external":
16+
# Starts a head-node for the cluster.
17+
cluster = Cluster(
18+
initialize_head=True,
19+
head_node_args={
20+
"num_cpus": 4,
21+
},
22+
)
23+
yield ParallelConfig(backend="ray", address=cluster.address)
24+
ray.shutdown()
25+
cluster.shutdown()

0 commit comments

Comments
 (0)