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

Commit fc08c62

Browse files
authored
Fix wrap_evaluation_matrices with xgb master (#215)
Compatibility fix for the latest xgboost master
1 parent ee1fc78 commit fc08c62

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,9 @@ jobs:
159159
timeout-minutes: 160
160160
strategy:
161161
matrix:
162-
python-version: [3.6.9, 3.7, 3.8]
162+
# no new versions for xgboost are published for 3.6
163+
python-version: [3.7, 3.8]
163164
include:
164-
- python-version: 3.6.9
165-
ray-wheel: https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray-2.0.0.dev0-cp36-cp36m-manylinux2014_x86_64.whl
166165
- python-version: 3.7
167166
ray-wheel: https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray-2.0.0.dev0-cp37-cp37m-manylinux2014_x86_64.whl
168167
- python-version: 3.8

xgboost_ray/sklearn.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def inner_f(*args, **kwargs):
5959
return inner_f
6060

6161

62+
# If _wrap_evaluation_matrices has new arguments added in xgboost, update
63+
# RayXGBMixin._ray_get_wrap_evaluation_matrices_compat_kwargs
6264
try:
6365
from xgboost.sklearn import _wrap_evaluation_matrices
6466
except ImportError:
@@ -358,13 +360,20 @@ def _ray_predict(
358360
def _ray_get_wrap_evaluation_matrices_compat_kwargs(
359361
self, label_transform=None) -> dict:
360362
ret = {}
361-
if "label_transform" in inspect.signature(
362-
_wrap_evaluation_matrices).parameters:
363+
wrap_evaluation_matrices_parameters = inspect.signature(
364+
_wrap_evaluation_matrices).parameters
365+
if "label_transform" in wrap_evaluation_matrices_parameters:
363366
# XGBoost < 1.6.0
364367
identity_func = lambda x: x # noqa
365368
ret["label_transform"] = label_transform or identity_func
366-
if hasattr(self, "enable_categorical"):
369+
if hasattr(
370+
self, "enable_categorical"
371+
) and "enable_categorical" in wrap_evaluation_matrices_parameters:
367372
ret["enable_categorical"] = self.enable_categorical
373+
if hasattr(
374+
self, "feature_types"
375+
) and "feature_types" in wrap_evaluation_matrices_parameters:
376+
ret["feature_types"] = self.feature_types
368377
return ret
369378

370379
# copied from the file in the top comment

0 commit comments

Comments
 (0)