From fedb1e6da3728522c59ca3307abdbe556a9974d7 Mon Sep 17 00:00:00 2001 From: Alexey Prutskov Date: Thu, 28 Jan 2021 18:20:55 +0300 Subject: [PATCH 1/4] FIX-#2658: Move backend check in xgb to funcs Signed-off-by: Alexey Prutskov --- modin/experimental/xgboost/xgboost.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modin/experimental/xgboost/xgboost.py b/modin/experimental/xgboost/xgboost.py index 27f366063ee..88ab88ba208 100644 --- a/modin/experimental/xgboost/xgboost.py +++ b/modin/experimental/xgboost/xgboost.py @@ -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]") @@ -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 as MODIN_ENGINE.") + result = _train( dtrain, nthread, evenly_data_distribution, params, *args, evals=evals, **kwargs ) @@ -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 as MODIN_ENGINE.") + if isinstance(model, xgb.Booster): booster = model elif isinstance(model, dict): From 56eceda95f0ab2fed15b88e42a57f9d207aa038b Mon Sep 17 00:00:00 2001 From: Alexey Prutskov Date: Fri, 29 Jan 2021 15:53:32 +0300 Subject: [PATCH 2/4] FIX-#2658: Add tests for backend check in xgb Signed-off-by: Alexey Prutskov --- .github/workflows/ci.yml | 4 +++ .github/workflows/push.yml | 4 +++ modin/experimental/xgboost/test/__init__.py | 12 ++++++++ .../experimental/xgboost/test/test_default.py | 30 +++++++++++++++++++ modin/experimental/xgboost/xgboost.py | 4 +-- 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 modin/experimental/xgboost/test/__init__.py create mode 100644 modin/experimental/xgboost/test/test_default.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61a6acd8ffa..5533ad86185 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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} @@ -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} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 6064522afcc..337a0a467dd 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -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} @@ -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} diff --git a/modin/experimental/xgboost/test/__init__.py b/modin/experimental/xgboost/test/__init__.py new file mode 100644 index 00000000000..cae6413e559 --- /dev/null +++ b/modin/experimental/xgboost/test/__init__.py @@ -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. diff --git a/modin/experimental/xgboost/test/test_default.py b/modin/experimental/xgboost/test/test_default.py new file mode 100644 index 00000000000..0fb7f751c1b --- /dev/null +++ b/modin/experimental/xgboost/test/test_default.py @@ -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 diff --git a/modin/experimental/xgboost/xgboost.py b/modin/experimental/xgboost/xgboost.py index 88ab88ba208..9896ea46f0b 100644 --- a/modin/experimental/xgboost/xgboost.py +++ b/modin/experimental/xgboost/xgboost.py @@ -98,7 +98,7 @@ def train( if Engine.get() == "Ray": from .xgboost_ray import _train else: - raise ValueError("Current version supports only Ray engine as MODIN_ENGINE.") + raise ValueError("Current version supports only Ray engine.") result = _train( dtrain, nthread, evenly_data_distribution, params, *args, evals=evals, **kwargs @@ -141,7 +141,7 @@ def predict( if Engine.get() == "Ray": from .xgboost_ray import _predict else: - raise ValueError("Current version supports only Ray engine as MODIN_ENGINE.") + raise ValueError("Current version supports only Ray engine.") if isinstance(model, xgb.Booster): booster = model From 2fb8ae99d94b84fbf7be329193ec7e62cd2cc6ce Mon Sep 17 00:00:00 2001 From: Alexey Prutskov Date: Fri, 29 Jan 2021 16:24:02 +0300 Subject: [PATCH 3/4] FIX-#2658: Add xgboost to dependencies list Signed-off-by: Alexey Prutskov --- environment-dev.yml | 1 + requirements-dev.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/environment-dev.yml b/environment-dev.yml index cc367348260..66d278c731c 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -34,3 +34,4 @@ dependencies: - boto3 - asv - ray-core >=1.0.0 + - py-xgboost >=1.3 diff --git a/requirements-dev.txt b/requirements-dev.txt index 61d6ed8c7cb..6d5406c0945 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -27,3 +27,4 @@ pandas_gbq cloudpickle rpyc==4.1.5 asv +xgboost>=1.3 From 58e67d6aa61da2cddfae433bdc4ef4121fe6ee97 Mon Sep 17 00:00:00 2001 From: Alexey Prutskov Date: Mon, 1 Feb 2021 12:19:57 +0300 Subject: [PATCH 4/4] FIX-#2658: Test pip deps in conda Signed-off-by: Alexey Prutskov --- environment-dev.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/environment-dev.yml b/environment-dev.yml index 66d278c731c..ffbc945271e 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -34,4 +34,5 @@ dependencies: - boto3 - asv - ray-core >=1.0.0 - - py-xgboost >=1.3 + - pip: + - xgboost >=1.3