Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit 57749f9

Browse files
authored
Separate out _RayXGBoostActor (#120)
1 parent 55ad540 commit 57749f9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

xgboost_ray/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ def _validate_ray_params(ray_params: Union[None, RayParams, dict]) \
358358
return ray_params
359359

360360

361-
@ray.remote
362361
class RayXGBoostActor:
363362
"""Remote Ray XGBoost actor class.
364363
@@ -613,6 +612,11 @@ def predict(self, model: xgb.Booster, data: RayDMatrix, **kwargs):
613612
return predictions
614613

615614

615+
@ray.remote
616+
class _RemoteRayXGBoostActor(RayXGBoostActor):
617+
pass
618+
619+
616620
class _PrepareActorTask(MultiActorTask):
617621
def __init__(self, actor: ActorHandle, queue: Queue, stop_event: Event,
618622
load_data: List[RayDMatrix]):
@@ -663,7 +667,7 @@ def _create_actor(
663667
# Send DEFAULT_PG here, which changed in Ray > 1.4.0
664668
# If we send `None`, this will ignore the parent placement group and
665669
# lead to errors e.g. when used within Ray Tune
666-
return RayXGBoostActor.options(
670+
return _RemoteRayXGBoostActor.options(
667671
num_cpus=num_cpus_per_actor,
668672
num_gpus=num_gpus_per_actor,
669673
resources=resources_per_actor,

xgboost_ray/tests/test_data_source.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ray import ObjectRef
1010

1111
from xgboost_ray.data_sources import Modin, Dask
12-
from xgboost_ray.main import RayXGBoostActor
12+
from xgboost_ray.main import _RemoteRayXGBoostActor
1313

1414
from xgboost_ray.data_sources.modin import MODIN_INSTALLED
1515
from xgboost_ray.data_sources.dask import DASK_INSTALLED
@@ -279,7 +279,7 @@ def create_remote_df(arr):
279279

280280
# Create ray actors
281281
actors = [
282-
RayXGBoostActor.options(resources={
282+
_RemoteRayXGBoostActor.options(resources={
283283
f"node:{nip}": 0.1
284284
}).remote(rank=rank, num_actors=len(actor_nodes))
285285
for rank, nip in enumerate(actor_node_ips)
@@ -414,7 +414,7 @@ def create_remote_df(arr):
414414

415415
# Create ray actors
416416
actors = [
417-
RayXGBoostActor.options(resources={
417+
_RemoteRayXGBoostActor.options(resources={
418418
f"node:{nip}": 0.1
419419
}).remote(rank=rank, num_actors=len(actor_nodes))
420420
for rank, nip in enumerate(actor_node_ips)

xgboost_ray/tests/test_fault_tolerance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def testSameResultWithAndWithoutError(self):
418418

419419
@patch("xgboost_ray.main._PrepareActorTask", _FakeTask)
420420
@patch("xgboost_ray.elastic._PrepareActorTask", _FakeTask)
421-
@patch("xgboost_ray.main.RayXGBoostActor", MagicMock)
421+
@patch("xgboost_ray.main._RemoteRayXGBoostActor", MagicMock)
422422
@patch("xgboost_ray.main.ELASTIC_RESTART_GRACE_PERIOD_S", 30)
423423
@patch("xgboost_ray.elastic.ELASTIC_RESTART_GRACE_PERIOD_S", 30)
424424
def testMaybeScheduleNewActors(self):

0 commit comments

Comments
 (0)