2018-07-12 18:43:59 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-04-23 03:28:51 +03:00
|
|
|
set -e -E -o -u pipefail
|
|
|
|
|
|
|
|
# defaults
|
2024-05-29 00:06:22 +03:00
|
|
|
CONDA_ENV="test-env"
|
2024-04-23 03:28:51 +03:00
|
|
|
IN_UBUNTU_BASE_CONTAINER=${IN_UBUNTU_BASE_CONTAINER:-"false"}
|
|
|
|
METHOD=${METHOD:-""}
|
|
|
|
PRODUCES_ARTIFACTS=${PRODUCES_ARTIFACTS:-"false"}
|
|
|
|
SANITIZERS=${SANITIZERS:-""}
|
2024-04-19 21:06:22 +03:00
|
|
|
|
2024-04-20 04:02:16 +03:00
|
|
|
ARCH=$(uname -m)
|
|
|
|
|
2024-06-21 20:16:41 +03:00
|
|
|
LGB_VER=$(head -n 1 "${BUILD_DIRECTORY}/VERSION.txt")
|
2024-05-23 05:03:55 +03:00
|
|
|
|
2018-09-17 12:16:03 +03:00
|
|
|
if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "gcc" ]]; then
|
2024-08-14 17:51:53 +03:00
|
|
|
export CXX=g++-12
|
|
|
|
export CC=gcc-12
|
2018-09-17 12:16:03 +03:00
|
|
|
elif [[ $OS_NAME == "linux" ]] && [[ $COMPILER == "clang" ]]; then
|
2018-09-12 13:32:09 +03:00
|
|
|
export CXX=clang++
|
|
|
|
export CC=clang
|
2023-12-19 20:18:51 +03:00
|
|
|
elif [[ $OS_NAME == "linux" ]] && [[ $COMPILER == "clang-17" ]]; then
|
|
|
|
export CXX=clang++-17
|
|
|
|
export CC=clang-17
|
2018-07-12 18:43:59 +03:00
|
|
|
fi
|
|
|
|
|
2022-12-28 10:19:46 +03:00
|
|
|
if [[ $IN_UBUNTU_BASE_CONTAINER == "true" ]]; then
|
|
|
|
export LANG="en_US.UTF-8"
|
|
|
|
export LC_ALL="en_US.UTF-8"
|
|
|
|
fi
|
|
|
|
|
2024-06-17 17:12:17 +03:00
|
|
|
# Setting MACOSX_DEPLOYMENT_TARGET prevents CMake from building against too-new
|
|
|
|
# macOS features, and helps tools like Python build tools determine the appropriate
|
|
|
|
# wheel compatibility tags.
|
|
|
|
#
|
|
|
|
# ref:
|
|
|
|
# * https://cmake.org/cmake/help/latest/envvar/MACOSX_DEPLOYMENT_TARGET.html
|
|
|
|
# * https://github.com/scikit-build/scikit-build-core/blob/acb7d0346e4a05bcb47a4ea3939c705ab71e3145/src/scikit_build_core/builder/macos.py#L36
|
|
|
|
if [[ $ARCH == "x86_64" ]]; then
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET=10.15
|
|
|
|
else
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET=12.0
|
|
|
|
fi
|
|
|
|
|
2024-10-29 13:47:25 +03:00
|
|
|
if [[ "${TASK}" == "r-package" ]]; then
|
2024-07-31 16:36:20 +03:00
|
|
|
bash "${BUILD_DIRECTORY}/.ci/test-r-package.sh" || exit 1
|
2020-11-18 00:33:20 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2021-04-16 16:22:46 +03:00
|
|
|
if [[ "$TASK" == "cpp-tests" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
cmake_args=(
|
|
|
|
-DBUILD_CPP_TEST=ON
|
|
|
|
-DUSE_DEBUG=ON
|
|
|
|
)
|
2021-06-26 15:26:07 +03:00
|
|
|
if [[ $METHOD == "with-sanitizers" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
cmake_args+=("-DUSE_SANITIZER=ON")
|
2021-06-26 15:26:07 +03:00
|
|
|
if [[ -n $SANITIZERS ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
cmake_args+=("-DENABLED_SANITIZERS=$SANITIZERS")
|
2021-06-26 15:26:07 +03:00
|
|
|
fi
|
|
|
|
fi
|
2024-10-13 23:56:16 +03:00
|
|
|
cmake -B build -S . "${cmake_args[@]}"
|
2024-03-20 20:21:46 +03:00
|
|
|
cmake --build build --target testlightgbm -j4 || exit 1
|
|
|
|
./testlightgbm || exit 1
|
2021-04-16 16:22:46 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-04-23 16:09:13 +03:00
|
|
|
# including python=version[build=*cpython] to ensure that conda doesn't fall back to pypy
|
2024-10-13 23:56:16 +03:00
|
|
|
CONDA_PYTHON_REQUIREMENT="python=${PYTHON_VERSION}[build=*cpython]"
|
2023-01-27 06:58:27 +03:00
|
|
|
|
|
|
|
if [[ $TASK == "if-else" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
conda create -q -y -n "${CONDA_ENV}" "${CONDA_PYTHON_REQUIREMENT}" numpy
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
source activate "${CONDA_ENV}"
|
2024-03-20 20:21:46 +03:00
|
|
|
cmake -B build -S . || exit 1
|
|
|
|
cmake --build build --target lightgbm -j4 || exit 1
|
2024-06-21 20:16:41 +03:00
|
|
|
cd "$BUILD_DIRECTORY/tests/cpp_tests"
|
|
|
|
../../lightgbm config=train.conf convert_model_language=cpp convert_model=../../src/boosting/gbdt_prediction.cpp
|
|
|
|
../../lightgbm config=predict.conf output_result=origin.pred
|
|
|
|
../../lightgbm config=predict.conf output_result=ifelse.pred
|
|
|
|
python test.py
|
2023-01-27 06:58:27 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-06-21 20:16:41 +03:00
|
|
|
cd "${BUILD_DIRECTORY}"
|
|
|
|
|
2023-01-27 06:58:27 +03:00
|
|
|
if [[ $TASK == "swig" ]]; then
|
2024-04-23 07:15:32 +03:00
|
|
|
cmake -B build -S . -DUSE_SWIG=ON
|
2024-03-20 20:21:46 +03:00
|
|
|
cmake --build build -j4 || exit 1
|
2023-01-27 06:58:27 +03:00
|
|
|
if [[ $OS_NAME == "linux" ]] && [[ $COMPILER == "gcc" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
objdump -T ./lib_lightgbm.so > ./objdump.log || exit 1
|
|
|
|
objdump -T ./lib_lightgbm_swig.so >> ./objdump.log || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
python ./.ci/check-dynamic-dependencies.py ./objdump.log || exit 1
|
2023-01-27 06:58:27 +03:00
|
|
|
fi
|
|
|
|
if [[ $PRODUCES_ARTIFACTS == "true" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
cp ./build/lightgbmlib.jar "${BUILD_ARTIFACTSTAGINGDIRECTORY}/lightgbmlib_${OS_NAME}.jar"
|
2023-01-27 06:58:27 +03:00
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $TASK == "lint" ]]; then
|
2024-10-30 01:49:43 +03:00
|
|
|
pwsh -command "Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -SkipPublisherCheck"
|
|
|
|
echo "Linting PowerShell code"
|
2024-11-03 22:12:20 +03:00
|
|
|
pwsh -file ./.ci/lint-powershell.ps1 || exit 1
|
2024-10-13 23:56:16 +03:00
|
|
|
conda create -q -y -n "${CONDA_ENV}" \
|
|
|
|
"${CONDA_PYTHON_REQUIREMENT}" \
|
2024-11-03 19:32:25 +03:00
|
|
|
'biome>=1.9.3' \
|
2024-08-15 04:51:22 +03:00
|
|
|
'cmakelint>=1.4.3' \
|
2024-03-19 05:17:48 +03:00
|
|
|
'cpplint>=1.6.0' \
|
2024-08-15 04:51:22 +03:00
|
|
|
'matplotlib-base>=3.9.1' \
|
|
|
|
'mypy>=1.11.1' \
|
|
|
|
'pre-commit>=3.8.0' \
|
|
|
|
'pyarrow-core>=17.0' \
|
2024-10-10 02:46:26 +03:00
|
|
|
'scikit-learn>=1.5.2' \
|
2024-06-03 06:12:27 +03:00
|
|
|
'r-lintr>=3.1.2'
|
2024-10-13 23:56:16 +03:00
|
|
|
# shellcheck disable=SC1091
|
|
|
|
source activate "${CONDA_ENV}"
|
2024-11-03 19:32:25 +03:00
|
|
|
echo "Linting Python and bash code"
|
|
|
|
bash ./.ci/lint-python-bash.sh || exit 1
|
2023-01-27 06:58:27 +03:00
|
|
|
echo "Linting R code"
|
2024-07-31 16:36:20 +03:00
|
|
|
Rscript ./.ci/lint-r-code.R "${BUILD_DIRECTORY}" || exit 1
|
2023-01-27 06:58:27 +03:00
|
|
|
echo "Linting C++ code"
|
2024-06-21 20:16:41 +03:00
|
|
|
bash ./.ci/lint-cpp.sh || exit 1
|
2024-11-03 19:32:25 +03:00
|
|
|
echo "Linting JavaScript code"
|
|
|
|
bash ./.ci/lint-js.sh || exit 1
|
2023-01-27 06:58:27 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2021-02-02 23:31:00 +03:00
|
|
|
if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then
|
2024-10-06 06:18:32 +03:00
|
|
|
conda env create \
|
2024-10-13 23:56:16 +03:00
|
|
|
-n "${CONDA_ENV}" \
|
|
|
|
--file ./docs/env.yml || exit 1
|
2024-10-06 06:18:32 +03:00
|
|
|
conda install \
|
2022-02-19 06:29:56 +03:00
|
|
|
-q \
|
|
|
|
-y \
|
2024-10-13 23:56:16 +03:00
|
|
|
-n "${CONDA_ENV}" \
|
2024-03-19 05:17:48 +03:00
|
|
|
'doxygen>=1.10.0' \
|
2024-08-15 04:51:22 +03:00
|
|
|
'rstcheck>=6.2.4' || exit 1
|
2024-10-13 23:56:16 +03:00
|
|
|
# shellcheck disable=SC1091
|
|
|
|
source activate "${CONDA_ENV}"
|
2018-09-17 12:16:03 +03:00
|
|
|
# check reStructuredText formatting
|
2024-10-13 23:56:16 +03:00
|
|
|
find "${BUILD_DIRECTORY}/python-package" -type f -name "*.rst" \
|
|
|
|
-exec rstcheck --report-level warning {} \+ || exit 1
|
|
|
|
find "${BUILD_DIRECTORY}/docs" -type f -name "*.rst" \
|
|
|
|
-exec rstcheck --report-level warning --ignore-directives=autoclass,autofunction,autosummary,doxygenfile {} \+ || exit 1
|
2021-02-02 23:31:00 +03:00
|
|
|
# build docs
|
2024-10-13 23:56:16 +03:00
|
|
|
make -C docs html || exit 1
|
2021-02-02 23:31:00 +03:00
|
|
|
if [[ $TASK == "check-links" ]]; then
|
|
|
|
# check docs for broken links
|
2024-05-27 18:03:34 +03:00
|
|
|
pip install linkchecker
|
2024-10-13 23:56:16 +03:00
|
|
|
linkchecker --config=.linkcheckerrc ./docs/_build/html/*.html || exit 1
|
2021-02-02 23:31:00 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
2018-09-17 12:16:03 +03:00
|
|
|
# check the consistency of parameters' descriptions and other stuff
|
2024-06-21 20:16:41 +03:00
|
|
|
cp ./docs/Parameters.rst ./docs/Parameters-backup.rst
|
|
|
|
cp ./src/io/config_auto.cpp ./src/io/config_auto-backup.cpp
|
2024-07-31 16:36:20 +03:00
|
|
|
python ./.ci/parameter-generator.py || exit 1
|
2024-06-21 20:16:41 +03:00
|
|
|
diff ./docs/Parameters-backup.rst ./docs/Parameters.rst || exit 1
|
|
|
|
diff ./src/io/config_auto-backup.cpp ./src/io/config_auto.cpp || exit 1
|
2018-09-17 12:16:03 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
2018-09-12 13:32:09 +03:00
|
|
|
|
2023-08-11 19:20:20 +03:00
|
|
|
if [[ $PYTHON_VERSION == "3.7" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
CONDA_REQUIREMENT_FILE="${BUILD_DIRECTORY}/.ci/conda-envs/ci-core-py37.txt"
|
2024-05-27 23:27:39 +03:00
|
|
|
elif [[ $PYTHON_VERSION == "3.8" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
CONDA_REQUIREMENT_FILE="${BUILD_DIRECTORY}/.ci/conda-envs/ci-core-py38.txt"
|
2024-04-23 16:09:13 +03:00
|
|
|
else
|
2024-10-13 23:56:16 +03:00
|
|
|
CONDA_REQUIREMENT_FILE="${BUILD_DIRECTORY}/.ci/conda-envs/ci-core.txt"
|
2023-08-11 19:20:20 +03:00
|
|
|
fi
|
|
|
|
|
2024-10-06 06:18:32 +03:00
|
|
|
conda create \
|
2024-04-23 16:09:13 +03:00
|
|
|
-y \
|
2024-10-13 23:56:16 +03:00
|
|
|
-n "${CONDA_ENV}" \
|
|
|
|
--file "${CONDA_REQUIREMENT_FILE}" \
|
|
|
|
"${CONDA_PYTHON_REQUIREMENT}" \
|
2024-04-23 16:09:13 +03:00
|
|
|
|| exit 1
|
2022-02-11 03:56:35 +03:00
|
|
|
|
2024-10-13 23:56:16 +03:00
|
|
|
# shellcheck disable=SC1091
|
2023-02-26 20:07:06 +03:00
|
|
|
source activate $CONDA_ENV
|
|
|
|
|
2024-06-21 20:16:41 +03:00
|
|
|
cd "${BUILD_DIRECTORY}"
|
2023-02-26 20:07:06 +03:00
|
|
|
|
2018-07-12 18:43:59 +03:00
|
|
|
if [[ $TASK == "sdist" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh sdist || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh .ci/check-python-dists.sh ./dist || exit 1
|
2024-10-13 23:56:16 +03:00
|
|
|
pip install "./dist/lightgbm-${LGB_VER}.tar.gz" -v || exit 1
|
2021-01-13 18:55:58 +03:00
|
|
|
if [[ $PRODUCES_ARTIFACTS == "true" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
cp "./dist/lightgbm-${LGB_VER}.tar.gz" "${BUILD_ARTIFACTSTAGINGDIRECTORY}" || exit 1
|
2018-09-17 12:16:03 +03:00
|
|
|
fi
|
2024-06-21 20:16:41 +03:00
|
|
|
pytest ./tests/python_package_test || exit 1
|
2018-07-12 18:43:59 +03:00
|
|
|
exit 0
|
|
|
|
elif [[ $TASK == "bdist" ]]; then
|
2018-09-17 12:16:03 +03:00
|
|
|
if [[ $OS_NAME == "macos" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh bdist_wheel || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh .ci/check-python-dists.sh ./dist || exit 1
|
2021-01-13 18:55:58 +03:00
|
|
|
if [[ $PRODUCES_ARTIFACTS == "true" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
cp "$(echo "dist/lightgbm-${LGB_VER}-py3-none-macosx"*.whl)" "${BUILD_ARTIFACTSTAGINGDIRECTORY}" || exit 1
|
2018-09-17 12:16:03 +03:00
|
|
|
fi
|
2018-07-12 18:43:59 +03:00
|
|
|
else
|
2021-02-16 23:35:37 +03:00
|
|
|
if [[ $ARCH == "x86_64" ]]; then
|
2022-11-27 04:41:35 +03:00
|
|
|
PLATFORM="manylinux_2_28_x86_64"
|
2021-02-16 23:35:37 +03:00
|
|
|
else
|
|
|
|
PLATFORM="manylinux2014_$ARCH"
|
|
|
|
fi
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh bdist_wheel --integrated-opencl || exit 1
|
2024-07-10 23:20:36 +03:00
|
|
|
# rename wheel, to fix scikit-build-core choosing the platform 'linux_aarch64' instead of
|
|
|
|
# a manylinux tag
|
2023-05-05 01:06:11 +03:00
|
|
|
mv \
|
|
|
|
./dist/*.whl \
|
2024-02-10 07:42:00 +03:00
|
|
|
./dist/tmp.whl || exit 1
|
2023-06-15 19:30:34 +03:00
|
|
|
mv \
|
|
|
|
./dist/tmp.whl \
|
2024-10-13 23:56:16 +03:00
|
|
|
"./dist/lightgbm-${LGB_VER}-py3-none-${PLATFORM}.whl" || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh .ci/check-python-dists.sh ./dist || exit 1
|
2021-01-13 18:55:58 +03:00
|
|
|
if [[ $PRODUCES_ARTIFACTS == "true" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
cp "dist/lightgbm-${LGB_VER}-py3-none-${PLATFORM}.whl" "${BUILD_ARTIFACTSTAGINGDIRECTORY}" || exit 1
|
2018-09-17 12:16:03 +03:00
|
|
|
fi
|
2022-12-02 06:10:31 +03:00
|
|
|
# Make sure we can do both CPU and GPU; see tests/python_package_test/test_dual.py
|
|
|
|
export LIGHTGBM_TEST_DUAL_CPU_GPU=1
|
2018-07-12 18:43:59 +03:00
|
|
|
fi
|
2024-06-21 20:16:41 +03:00
|
|
|
pip install -v ./dist/*.whl || exit 1
|
|
|
|
pytest ./tests || exit 1
|
2018-07-12 18:43:59 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $TASK == "gpu" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sed -i'.bak' 's/std::string device_type = "cpu";/std::string device_type = "gpu";/' ./include/LightGBM/config.h
|
|
|
|
grep -q 'std::string device_type = "gpu"' ./include/LightGBM/config.h || exit 1 # make sure that changes were really done
|
2018-07-12 18:43:59 +03:00
|
|
|
if [[ $METHOD == "pip" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh sdist || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh .ci/check-python-dists.sh ./dist || exit 1
|
2023-05-27 14:27:26 +03:00
|
|
|
pip install \
|
|
|
|
-v \
|
2023-06-15 19:30:34 +03:00
|
|
|
--config-settings=cmake.define.USE_GPU=ON \
|
2024-10-13 23:56:16 +03:00
|
|
|
"./dist/lightgbm-${LGB_VER}.tar.gz" \
|
2024-02-10 07:42:00 +03:00
|
|
|
|| exit 1
|
2024-06-21 20:16:41 +03:00
|
|
|
pytest ./tests/python_package_test || exit 1
|
2018-07-12 18:43:59 +03:00
|
|
|
exit 0
|
2020-11-26 15:13:41 +03:00
|
|
|
elif [[ $METHOD == "wheel" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh bdist_wheel --gpu || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh ./.ci/check-python-dists.sh ./dist || exit 1
|
2024-10-13 23:56:16 +03:00
|
|
|
pip install "$(echo "./dist/lightgbm-${LGB_VER}"*.whl)" -v || exit 1
|
2024-06-21 20:16:41 +03:00
|
|
|
pytest ./tests || exit 1
|
2020-11-26 15:13:41 +03:00
|
|
|
exit 0
|
|
|
|
elif [[ $METHOD == "source" ]]; then
|
2024-03-20 20:21:46 +03:00
|
|
|
cmake -B build -S . -DUSE_GPU=ON
|
2018-07-12 18:43:59 +03:00
|
|
|
fi
|
2023-02-01 06:27:52 +03:00
|
|
|
elif [[ $TASK == "cuda" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sed -i'.bak' 's/std::string device_type = "cpu";/std::string device_type = "cuda";/' ./include/LightGBM/config.h
|
|
|
|
grep -q 'std::string device_type = "cuda"' ./include/LightGBM/config.h || exit 1 # make sure that changes were really done
|
2023-02-01 06:27:52 +03:00
|
|
|
# by default ``gpu_use_dp=false`` for efficiency. change to ``true`` here for exact results in ci tests
|
2024-06-21 20:16:41 +03:00
|
|
|
sed -i'.bak' 's/gpu_use_dp = false;/gpu_use_dp = true;/' ./include/LightGBM/config.h
|
|
|
|
grep -q 'gpu_use_dp = true' ./include/LightGBM/config.h || exit 1 # make sure that changes were really done
|
2020-09-20 08:35:01 +03:00
|
|
|
if [[ $METHOD == "pip" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh sdist || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh ./.ci/check-python-dists.sh ./dist || exit 1
|
2023-05-27 14:27:26 +03:00
|
|
|
pip install \
|
|
|
|
-v \
|
2023-06-15 19:30:34 +03:00
|
|
|
--config-settings=cmake.define.USE_CUDA=ON \
|
2024-10-13 23:56:16 +03:00
|
|
|
"./dist/lightgbm-${LGB_VER}.tar.gz" \
|
2024-02-10 07:42:00 +03:00
|
|
|
|| exit 1
|
2024-06-21 20:16:41 +03:00
|
|
|
pytest ./tests/python_package_test || exit 1
|
2020-09-20 08:35:01 +03:00
|
|
|
exit 0
|
2020-11-26 15:13:41 +03:00
|
|
|
elif [[ $METHOD == "wheel" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh bdist_wheel --cuda || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh ./.ci/check-python-dists.sh ./dist || exit 1
|
2024-10-13 23:56:16 +03:00
|
|
|
pip install "$(echo "./dist/lightgbm-${LGB_VER}"*.whl)" -v || exit 1
|
2024-06-21 20:16:41 +03:00
|
|
|
pytest ./tests || exit 1
|
2020-11-26 15:13:41 +03:00
|
|
|
exit 0
|
|
|
|
elif [[ $METHOD == "source" ]]; then
|
2024-03-20 20:21:46 +03:00
|
|
|
cmake -B build -S . -DUSE_CUDA=ON
|
2020-09-20 08:35:01 +03:00
|
|
|
fi
|
2018-11-06 17:18:17 +03:00
|
|
|
elif [[ $TASK == "mpi" ]]; then
|
2018-09-12 13:32:09 +03:00
|
|
|
if [[ $METHOD == "pip" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh sdist || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh ./.ci/check-python-dists.sh ./dist || exit 1
|
2023-05-27 14:27:26 +03:00
|
|
|
pip install \
|
|
|
|
-v \
|
2023-06-15 19:30:34 +03:00
|
|
|
--config-settings=cmake.define.USE_MPI=ON \
|
2024-10-13 23:56:16 +03:00
|
|
|
"./dist/lightgbm-${LGB_VER}.tar.gz" \
|
2024-02-10 07:42:00 +03:00
|
|
|
|| exit 1
|
2024-06-21 20:16:41 +03:00
|
|
|
pytest ./tests/python_package_test || exit 1
|
2018-09-12 13:32:09 +03:00
|
|
|
exit 0
|
2020-11-26 15:13:41 +03:00
|
|
|
elif [[ $METHOD == "wheel" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh bdist_wheel --mpi || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
sh ./.ci/check-python-dists.sh ./dist || exit 1
|
2024-10-13 23:56:16 +03:00
|
|
|
pip install "$(echo "./dist/lightgbm-${LGB_VER}"*.whl)" -v || exit 1
|
2024-06-21 20:16:41 +03:00
|
|
|
pytest ./tests || exit 1
|
2020-11-26 15:13:41 +03:00
|
|
|
exit 0
|
|
|
|
elif [[ $METHOD == "source" ]]; then
|
2024-03-20 20:21:46 +03:00
|
|
|
cmake -B build -S . -DUSE_MPI=ON -DUSE_DEBUG=ON
|
2018-09-12 13:32:09 +03:00
|
|
|
fi
|
2018-07-12 18:43:59 +03:00
|
|
|
else
|
2024-03-20 20:21:46 +03:00
|
|
|
cmake -B build -S .
|
2018-07-12 18:43:59 +03:00
|
|
|
fi
|
|
|
|
|
2024-03-20 20:21:46 +03:00
|
|
|
cmake --build build --target _lightgbm -j4 || exit 1
|
2018-07-12 18:43:59 +03:00
|
|
|
|
2024-06-21 20:16:41 +03:00
|
|
|
sh ./build-python.sh install --precompile || exit 1
|
|
|
|
pytest ./tests || exit 1
|
2018-07-12 18:43:59 +03:00
|
|
|
|
|
|
|
if [[ $TASK == "regular" ]]; then
|
2021-01-13 18:55:58 +03:00
|
|
|
if [[ $PRODUCES_ARTIFACTS == "true" ]]; then
|
2018-09-17 12:16:03 +03:00
|
|
|
if [[ $OS_NAME == "macos" ]]; then
|
2024-10-13 23:56:16 +03:00
|
|
|
cp ./lib_lightgbm.dylib "${BUILD_ARTIFACTSTAGINGDIRECTORY}/lib_lightgbm.dylib"
|
2018-09-17 12:16:03 +03:00
|
|
|
else
|
2018-11-01 04:42:06 +03:00
|
|
|
if [[ $COMPILER == "gcc" ]]; then
|
2024-06-21 20:16:41 +03:00
|
|
|
objdump -T ./lib_lightgbm.so > ./objdump.log || exit 1
|
2024-07-31 16:36:20 +03:00
|
|
|
python ./.ci/check-dynamic-dependencies.py ./objdump.log || exit 1
|
2018-11-01 04:42:06 +03:00
|
|
|
fi
|
2024-10-13 23:56:16 +03:00
|
|
|
cp ./lib_lightgbm.so "${BUILD_ARTIFACTSTAGINGDIRECTORY}/lib_lightgbm.so"
|
2018-09-17 12:16:03 +03:00
|
|
|
fi
|
2018-07-12 18:43:59 +03:00
|
|
|
fi
|
2024-06-21 20:16:41 +03:00
|
|
|
cd "$BUILD_DIRECTORY/examples/python-guide"
|
2018-07-12 18:43:59 +03:00
|
|
|
sed -i'.bak' '/import lightgbm as lgb/a\
|
|
|
|
import matplotlib\
|
|
|
|
matplotlib.use\(\"Agg\"\)\
|
|
|
|
' plot_example.py # prevent interactive window mode
|
2018-09-12 13:32:09 +03:00
|
|
|
sed -i'.bak' 's/graph.render(view=True)/graph.render(view=False)/' plot_example.py
|
2022-02-11 03:56:35 +03:00
|
|
|
# requirements for examples
|
2024-10-06 06:18:32 +03:00
|
|
|
conda install -y -n $CONDA_ENV \
|
2024-04-23 16:09:13 +03:00
|
|
|
'h5py>=3.10' \
|
|
|
|
'ipywidgets>=8.1.2' \
|
|
|
|
'notebook>=7.1.2'
|
2024-10-13 23:56:16 +03:00
|
|
|
for f in *.py **/*.py; do python "${f}" || exit 1; done # run all examples
|
2024-06-21 20:16:41 +03:00
|
|
|
cd "$BUILD_DIRECTORY/examples/python-guide/notebooks"
|
2021-07-04 06:50:44 +03:00
|
|
|
sed -i'.bak' 's/INTERACTIVE = False/assert False, \\"Interactive mode disabled\\"/' interactive_plot_example.ipynb
|
2024-10-13 23:56:16 +03:00
|
|
|
jupyter nbconvert --ExecutePreprocessor.timeout=180 --to notebook --execute --inplace ./*.ipynb || exit 1 # run all notebooks
|
2022-12-29 05:16:26 +03:00
|
|
|
|
|
|
|
# importing the library should succeed even if all optional dependencies are not present
|
2024-01-23 01:11:10 +03:00
|
|
|
conda uninstall -n $CONDA_ENV --force --yes \
|
2023-11-01 16:21:48 +03:00
|
|
|
cffi \
|
2024-03-18 05:26:26 +03:00
|
|
|
dask \
|
2022-12-29 05:16:26 +03:00
|
|
|
distributed \
|
|
|
|
joblib \
|
2024-04-23 16:09:13 +03:00
|
|
|
matplotlib-base \
|
2022-12-29 05:16:26 +03:00
|
|
|
psutil \
|
2023-11-01 16:21:48 +03:00
|
|
|
pyarrow \
|
2022-12-29 05:16:26 +03:00
|
|
|
python-graphviz \
|
2024-02-10 07:42:00 +03:00
|
|
|
scikit-learn || exit 1
|
|
|
|
python -c "import lightgbm" || exit 1
|
2018-07-12 18:43:59 +03:00
|
|
|
fi
|