Skip to content

Commit 9495ff7

Browse files
authored
FIX-#2658: Move backend check in xgb to train/predict (#2659)
Signed-off-by: Alexey Prutskov <[email protected]>
1 parent e25a5e0 commit 9495ff7

File tree

7 files changed

+64
-5
lines changed

7 files changed

+64
-5
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ jobs:
220220
conda list
221221
- name: Install HDF5
222222
run: sudo apt update && sudo apt install -y libhdf5-dev
223+
- shell: bash -l {0}
224+
run: pytest modin/experimental/xgboost/test/test_default.py --backend=${{ matrix.backend }}
223225
- shell: bash -l {0}
224226
run: python -m pytest modin/test/backends/base/test_internals.py --backend=${{ matrix.backend }}
225227
- shell: bash -l {0}
@@ -368,6 +370,8 @@ jobs:
368370
conda list
369371
- name: Install HDF5
370372
run: sudo apt update && sudo apt install -y libhdf5-dev
373+
- shell: bash -l {0}
374+
run: pytest modin/experimental/xgboost/test/test_default.py
371375
- shell: bash -l {0}
372376
run: pytest modin/pandas/test/dataframe/test_binary.py
373377
- shell: bash -l {0}

.github/workflows/push.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ jobs:
6161
conda list
6262
- name: Install HDF5
6363
run: sudo apt update && sudo apt install -y libhdf5-dev
64+
- shell: bash -l {0}
65+
run: pytest modin/experimental/xgboost/test/test_default.py --backend=${{ matrix.backend }}
6466
- shell: bash -l {0}
6567
run: pytest modin/pandas/test/dataframe/test_binary.py --backend=${{ matrix.backend }}
6668
- shell: bash -l {0}
@@ -154,6 +156,8 @@ jobs:
154156
conda list
155157
- name: Install HDF5
156158
run: sudo apt update && sudo apt install -y libhdf5-dev
159+
- shell: bash -l {0}
160+
run: pytest modin/experimental/xgboost/test/test_default.py
157161
- shell: bash -l {0}
158162
run: pytest modin/pandas/test/dataframe/test_binary.py
159163
- shell: bash -l {0}

environment-dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ dependencies:
3434
- boto3
3535
- asv
3636
- ray-core >=1.0.0
37+
- pip:
38+
- xgboost >=1.3
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Licensed to Modin Development Team under one or more contributor license agreements.
2+
# See the NOTICE file distributed with this work for additional information regarding
3+
# copyright ownership. The Modin Development Team licenses this file to you under the
4+
# Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
# compliance with the License. You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software distributed under
10+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific language
12+
# governing permissions and limitations under the License.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Licensed to Modin Development Team under one or more contributor license agreements.
2+
# See the NOTICE file distributed with this work for additional information regarding
3+
# copyright ownership. The Modin Development Team licenses this file to you under the
4+
# Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
# compliance with the License. You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software distributed under
10+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific language
12+
# governing permissions and limitations under the License.
13+
14+
15+
import pytest
16+
from modin.config import Engine
17+
18+
import modin.experimental.xgboost as xgb
19+
20+
21+
@pytest.mark.skipif(
22+
Engine.get() == "Ray",
23+
reason="This test doesn't make sense on Ray backend.",
24+
)
25+
@pytest.mark.parametrize("func", ["train", "predict"])
26+
def test_backend(func):
27+
try:
28+
getattr(xgb, func)({}, xgb.ModinDMatrix(None, None))
29+
except ValueError:
30+
pass

modin/experimental/xgboost/xgboost.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020

2121
from modin.config import Engine
2222

23-
if Engine.get() == "Ray":
24-
from .xgboost_ray import _train, _predict
25-
else:
26-
raise ValueError("Current version supports only Ray engine as MODIN_ENGINE.")
27-
2823
LOGGER = logging.getLogger("[modin.xgboost]")
2924

3025

@@ -99,6 +94,12 @@ def train(
9994
'eval': {'logloss': ['0.480385', '0.357756']}}}
10095
"""
10196
LOGGER.info("Training started")
97+
98+
if Engine.get() == "Ray":
99+
from .xgboost_ray import _train
100+
else:
101+
raise ValueError("Current version supports only Ray engine.")
102+
102103
result = _train(
103104
dtrain, nthread, evenly_data_distribution, params, *args, evals=evals, **kwargs
104105
)
@@ -137,6 +138,11 @@ def predict(
137138
"""
138139
LOGGER.info("Prediction started")
139140

141+
if Engine.get() == "Ray":
142+
from .xgboost_ray import _predict
143+
else:
144+
raise ValueError("Current version supports only Ray engine.")
145+
140146
if isinstance(model, xgb.Booster):
141147
booster = model
142148
elif isinstance(model, dict):

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ pandas_gbq
2727
cloudpickle
2828
rpyc==4.1.5
2929
asv
30+
xgboost>=1.3

0 commit comments

Comments
 (0)