Skip to content

Commit 61dce36

Browse files
authored
Merge branch 'develop' into fix/cleanup
2 parents 16da2bd + 777b3e9 commit 61dce36

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
adds `extra_values` argument to `ValuationResult`,
2828
adds `compute_removal_score()` and `compute_random_removal_score()` helper functions
2929
[PR #237](https://github.com/appliedAI-Initiative/pyDVL/pull/237)
30+
- Fixes bug in ray initialization in `RayParallelBackend` class
31+
[PR #239](https://github.com/appliedAI-Initiative/pyDVL/pull/239)
3032

3133
## 0.3.0 - 💥 Breaking changes
3234

src/pydvl/utils/parallel/backend.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ def __init__(self, config: ParallelConfig):
136136
config_dict.pop("backend")
137137
config_dict["num_cpus"] = config_dict.pop("n_local_workers")
138138
self.config = config_dict
139-
if self.config["address"] is None:
140-
self.config["ignore_reinit_error"] = True
141-
ray.init(**self.config)
139+
if not ray.is_initialized():
140+
ray.init(**self.config)
142141

143142
def get(
144143
self,
@@ -200,7 +199,7 @@ def init_parallel_backend(
200199
>>> config = ParallelConfig(backend="ray")
201200
>>> parallel_backend = init_parallel_backend(config)
202201
>>> parallel_backend
203-
<RayParallelBackend: {'address': None, 'logging_level': 30, 'num_cpus': None, 'ignore_reinit_error': True}>
202+
<RayParallelBackend: {'address': None, 'logging_level': 30, 'num_cpus': None}>
204203
205204
"""
206205
try:

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)