Skip to content

Commit

Permalink
FIX-#2658: Move backend check in xgb to train/predict (#2659)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Prutskov <alexey.prutskov@intel.com>
  • Loading branch information
prutskov committed Feb 3, 2021
1 parent e25a5e0 commit 9495ff7
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ jobs:
conda list
- name: Install HDF5
run: sudo apt update && sudo apt install -y libhdf5-dev
- shell: bash -l {0}
run: pytest modin/experimental/xgboost/test/test_default.py --backend=${{ matrix.backend }}
- shell: bash -l {0}
run: python -m pytest modin/test/backends/base/test_internals.py --backend=${{ matrix.backend }}
- shell: bash -l {0}
Expand Down Expand Up @@ -368,6 +370,8 @@ jobs:
conda list
- name: Install HDF5
run: sudo apt update && sudo apt install -y libhdf5-dev
- shell: bash -l {0}
run: pytest modin/experimental/xgboost/test/test_default.py
- shell: bash -l {0}
run: pytest modin/pandas/test/dataframe/test_binary.py
- shell: bash -l {0}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
conda list
- name: Install HDF5
run: sudo apt update && sudo apt install -y libhdf5-dev
- shell: bash -l {0}
run: pytest modin/experimental/xgboost/test/test_default.py --backend=${{ matrix.backend }}
- shell: bash -l {0}
run: pytest modin/pandas/test/dataframe/test_binary.py --backend=${{ matrix.backend }}
- shell: bash -l {0}
Expand Down Expand Up @@ -154,6 +156,8 @@ jobs:
conda list
- name: Install HDF5
run: sudo apt update && sudo apt install -y libhdf5-dev
- shell: bash -l {0}
run: pytest modin/experimental/xgboost/test/test_default.py
- shell: bash -l {0}
run: pytest modin/pandas/test/dataframe/test_binary.py
- shell: bash -l {0}
Expand Down
2 changes: 2 additions & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ dependencies:
- boto3
- asv
- ray-core >=1.0.0
- pip:
- xgboost >=1.3
12 changes: 12 additions & 0 deletions modin/experimental/xgboost/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Licensed to Modin Development Team under one or more contributor license agreements.
# See the NOTICE file distributed with this work for additional information regarding
# copyright ownership. The Modin Development Team licenses this file to you under the
# Apache License, Version 2.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
30 changes: 30 additions & 0 deletions modin/experimental/xgboost/test/test_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Licensed to Modin Development Team under one or more contributor license agreements.
# See the NOTICE file distributed with this work for additional information regarding
# copyright ownership. The Modin Development Team licenses this file to you under the
# Apache License, Version 2.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.


import pytest
from modin.config import Engine

import modin.experimental.xgboost as xgb


@pytest.mark.skipif(
Engine.get() == "Ray",
reason="This test doesn't make sense on Ray backend.",
)
@pytest.mark.parametrize("func", ["train", "predict"])
def test_backend(func):
try:
getattr(xgb, func)({}, xgb.ModinDMatrix(None, None))
except ValueError:
pass
16 changes: 11 additions & 5 deletions modin/experimental/xgboost/xgboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@

from modin.config import Engine

if Engine.get() == "Ray":
from .xgboost_ray import _train, _predict
else:
raise ValueError("Current version supports only Ray engine as MODIN_ENGINE.")

LOGGER = logging.getLogger("[modin.xgboost]")


Expand Down Expand Up @@ -99,6 +94,12 @@ def train(
'eval': {'logloss': ['0.480385', '0.357756']}}}
"""
LOGGER.info("Training started")

if Engine.get() == "Ray":
from .xgboost_ray import _train
else:
raise ValueError("Current version supports only Ray engine.")

result = _train(
dtrain, nthread, evenly_data_distribution, params, *args, evals=evals, **kwargs
)
Expand Down Expand Up @@ -137,6 +138,11 @@ def predict(
"""
LOGGER.info("Prediction started")

if Engine.get() == "Ray":
from .xgboost_ray import _predict
else:
raise ValueError("Current version supports only Ray engine.")

if isinstance(model, xgb.Booster):
booster = model
elif isinstance(model, dict):
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ pandas_gbq
cloudpickle
rpyc==4.1.5
asv
xgboost>=1.3

0 comments on commit 9495ff7

Please sign in to comment.