From b044070e21680c0c71b50138cebaf4285083b1c1 Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Mon, 15 Mar 2021 05:58:15 +0300 Subject: [PATCH] [ci] run Dask examples on CI (#4064) * Update Parallel-Learning-Guide.rst * Update test.sh * fix path * address review comments --- .ci/test.sh | 2 +- docs/Parallel-Learning-Guide.rst | 6 +++++- examples/python-guide/dask/binary-classification.py | 1 - examples/python-guide/dask/multiclass-classification.py | 1 - examples/python-guide/dask/prediction.py | 1 - examples/python-guide/dask/ranking.py | 9 ++++++--- examples/python-guide/dask/regression.py | 1 - python-package/README.rst | 4 ++++ 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.ci/test.sh b/.ci/test.sh index e66790866d77..65eac1b58225 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -224,7 +224,7 @@ import matplotlib\ matplotlib.use\(\"Agg\"\)\ ' plot_example.py # prevent interactive window mode sed -i'.bak' 's/graph.render(view=True)/graph.render(view=False)/' plot_example.py - for f in *.py; do python $f || exit -1; done # run all examples + for f in *.py **/*.py; do python $f || exit -1; done # run all examples cd $BUILD_DIRECTORY/examples/python-guide/notebooks conda install -q -y -n $CONDA_ENV ipywidgets notebook jupyter nbconvert --ExecutePreprocessor.timeout=180 --to notebook --execute --inplace *.ipynb || exit -1 # run all notebooks diff --git a/docs/Parallel-Learning-Guide.rst b/docs/Parallel-Learning-Guide.rst index 9486a0d8cd23..7bcb3fdfa865 100644 --- a/docs/Parallel-Learning-Guide.rst +++ b/docs/Parallel-Learning-Guide.rst @@ -62,10 +62,14 @@ Dask LightGBM's Python package supports distributed learning via `Dask`_. This integration is maintained by LightGBM's maintainers. +.. warning:: + + Dask integration is only tested on Linux. + Dask Examples ''''''''''''' -For sample code using ``lightgbm.dask``, see `these Dask examples`_ . +For sample code using ``lightgbm.dask``, see `these Dask examples`_. Training with Dask '''''''''''''''''' diff --git a/examples/python-guide/dask/binary-classification.py b/examples/python-guide/dask/binary-classification.py index 4313e8da3ddb..4de9245d4472 100644 --- a/examples/python-guide/dask/binary-classification.py +++ b/examples/python-guide/dask/binary-classification.py @@ -5,7 +5,6 @@ import lightgbm as lgb if __name__ == "__main__": - print("loading data") X, y = make_blobs(n_samples=1000, n_features=50, centers=2) diff --git a/examples/python-guide/dask/multiclass-classification.py b/examples/python-guide/dask/multiclass-classification.py index 8e40b35a8121..bcda9589ab84 100644 --- a/examples/python-guide/dask/multiclass-classification.py +++ b/examples/python-guide/dask/multiclass-classification.py @@ -5,7 +5,6 @@ import lightgbm as lgb if __name__ == "__main__": - print("loading data") X, y = make_blobs(n_samples=1000, n_features=50, centers=3) diff --git a/examples/python-guide/dask/prediction.py b/examples/python-guide/dask/prediction.py index 64e2bae0c08d..a4cb5cd8592e 100644 --- a/examples/python-guide/dask/prediction.py +++ b/examples/python-guide/dask/prediction.py @@ -6,7 +6,6 @@ import lightgbm as lgb if __name__ == "__main__": - print("loading data") X, y = make_regression(n_samples=1000, n_features=50) diff --git a/examples/python-guide/dask/ranking.py b/examples/python-guide/dask/ranking.py index b7cae20a44c4..5693ed9a5b67 100644 --- a/examples/python-guide/dask/ranking.py +++ b/examples/python-guide/dask/ranking.py @@ -1,3 +1,5 @@ +import os + import dask.array as da import numpy as np from distributed import Client, LocalCluster @@ -6,11 +8,12 @@ import lightgbm as lgb if __name__ == "__main__": - print("loading data") - X, y = load_svmlight_file("../lambdarank/rank.train") - group = np.loadtxt("../lambdarank/rank.train.query") + X, y = load_svmlight_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), + '../../lambdarank/rank.train')) + group = np.loadtxt(os.path.join(os.path.dirname(os.path.realpath(__file__)), + '../../lambdarank/rank.train.query')) print("initializing a Dask cluster") diff --git a/examples/python-guide/dask/regression.py b/examples/python-guide/dask/regression.py index 69a8f764732d..4d15547ff501 100644 --- a/examples/python-guide/dask/regression.py +++ b/examples/python-guide/dask/regression.py @@ -5,7 +5,6 @@ import lightgbm as lgb if __name__ == "__main__": - print("loading data") X, y = make_regression(n_samples=1000, n_features=50) diff --git a/python-package/README.rst b/python-package/README.rst index 7f4d2d35726b..c6da99229b0e 100644 --- a/python-package/README.rst +++ b/python-package/README.rst @@ -204,6 +204,10 @@ You can use ``python setup.py bdist_wheel`` instead of ``python setup.py install Install Dask-package '''''''''''''''''''' +.. warning:: + + Dask-package is only tested on Linux. + To install all additional dependencies required for Dask-package, you can append ``[dask]`` to LightGBM package name: .. code:: sh