Skip to content

Commit af48add

Browse files
Merge branch 'master' of https://github.com/Microsoft/LightGBM into ponnuswami-dcgPositionLimit
2 parents 73e7ab4 + bcf443b commit af48add

29 files changed

+799
-78
lines changed

.ci/test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,19 @@ if [[ $TASK == "swig" ]]; then
9696
exit 0
9797
fi
9898

99-
conda install -q -y -n $CONDA_ENV cloudpickle dask distributed joblib matplotlib numpy pandas psutil pytest scikit-learn scipy
99+
conda install -q -y -n $CONDA_ENV cloudpickle joblib matplotlib numpy pandas psutil pytest scikit-learn scipy
100100

101101
# graphviz must come from conda-forge to avoid this on some linux distros:
102102
# https://github.com/conda-forge/graphviz-feedstock/issues/18
103+
#
104+
# dask and distributed must come from conda-forge because they need to be kept
105+
# in sync and conda-forge packages are updated more quickly (automatically based
106+
# on pushes to PyPI)
103107
conda install -q -y \
104108
-n $CONDA_ENV \
105109
-c conda-forge \
110+
'dask>=2021.3.0' \
111+
'distributed>=2021.3.0' \
106112
python-graphviz \
107113
xorg-libxau
108114

.ci/test_r_package.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ export _R_CHECK_CRAN_INCOMING_REMOTE_=0
2020
# to catch extreme problems
2121
export _R_CHECK_PKG_SIZES_THRESHOLD_=60
2222

23+
# don't fail builds for long-running examples unless they're very long.
24+
# See https://github.com/microsoft/LightGBM/issues/4049#issuecomment-793412254.
25+
if [[ $R_BUILD_TYPE != "cran" ]]; then
26+
export _R_CHECK_EXAMPLE_TIMING_THRESHOLD_=30
27+
fi
28+
2329
# Get details needed for installing R components
2430
R_MAJOR_VERSION=( ${R_VERSION//./ } )
2531
if [[ "${R_MAJOR_VERSION}" == "3" ]]; then

.ci/test_r_package_windows.ps1

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ function Run-R-Code-Redirect-Stderr {
2828
Rscript --vanilla -e $decorated_code
2929
}
3030

31+
# Remove all items matching some pattern from PATH environment variable
32+
function Remove-From-Path {
33+
param(
34+
[string]$pattern_to_remove
35+
)
36+
$env:PATH = ($env:PATH.Split(';') | Where-Object { $_ -notmatch "$pattern_to_remove" }) -join ';'
37+
}
38+
39+
# remove some details that exist in the GitHub Actions images which might
40+
# cause conflicts with R and other components installed by this script
41+
$env:RTOOLS40_HOME = ""
42+
Remove-From-Path ".*chocolatey.*"
43+
Remove-From-Path ".*Chocolatey.*"
44+
Remove-From-Path ".*Git.*mingw64.*"
45+
Remove-From-Path ".*msys64.*"
46+
Remove-From-Path ".*rtools40.*"
47+
Remove-From-Path ".*Strawberry.*"
48+
49+
Remove-Item C:\rtools40 -Force -Recurse -ErrorAction Ignore
50+
3151
# Get details needed for installing R components
3252
#
3353
# NOTES:
@@ -72,6 +92,12 @@ $env:_R_CHECK_CRAN_INCOMING_REMOTE_ = 0
7292
# to catch extreme problems
7393
$env:_R_CHECK_PKG_SIZES_THRESHOLD_ = 60
7494

95+
# don't fail builds for long-running examples unless they're very long.
96+
# See https://github.com/microsoft/LightGBM/issues/4049#issuecomment-793412254.
97+
if ($env:R_BUILD_TYPE -ne "cran") {
98+
$env:_R_CHECK_EXAMPLE_TIMING_THRESHOLD_ = 30
99+
}
100+
75101
if (($env:COMPILER -eq "MINGW") -and ($env:R_BUILD_TYPE -eq "cmake")) {
76102
$env:CXX = "$env:RTOOLS_MINGW_BIN/g++.exe"
77103
$env:CC = "$env:RTOOLS_MINGW_BIN/gcc.exe"
@@ -92,7 +118,7 @@ Start-Process -FilePath R-win.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT
92118
Write-Output "Done installing R"
93119

94120
Write-Output "Installing Rtools"
95-
./Rtools.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=$RTOOLS_INSTALL_PATH ; Check-Output $?
121+
Start-Process -FilePath Rtools.exe -NoNewWindow -Wait -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /DIR=$RTOOLS_INSTALL_PATH" ; Check-Output $?
96122
Write-Output "Done installing Rtools"
97123

98124
Write-Output "Installing dependencies"

.github/CODEOWNERS

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@
1111

1212
# other catch-alls that will get matched if specific rules below are not matched
1313
*.R @Laurae2 @jameslamb
14-
*.py @StrikerRUS @chivee @wxchan @henry0312
15-
*.cpp @guolinke @chivee @btrotta
16-
*.h @guolinke @chivee @btrotta
14+
*.py @StrikerRUS @chivee @wxchan @henry0312 @shiyu1994
15+
*.cpp @guolinke @chivee @btrotta @shiyu1994
16+
*.h @guolinke @chivee @btrotta @shiyu1994
1717

1818
# main C++ code
19-
include/ @guolinke @chivee @btrotta
20-
src/ @guolinke @chivee @btrotta
21-
CMakeLists.txt @guolinke @chivee @Laurae2 @jameslamb @wxchan @henry0312 @StrikerRUS @huanzhang12 @btrotta
22-
tests/c_api_test/ @guolinke @chivee @btrotta
23-
tests/cpp_test/ @guolinke @chivee @btrotta
24-
tests/data/ @guolinke @chivee @btrotta
25-
windows/ @guolinke @chivee @btrotta @StrikerRUS
19+
include/ @guolinke @chivee @btrotta @shiyu1994
20+
src/ @guolinke @chivee @btrotta @shiyu1994
21+
CMakeLists.txt @guolinke @chivee @Laurae2 @jameslamb @wxchan @henry0312 @StrikerRUS @huanzhang12 @btrotta @shiyu1994
22+
tests/c_api_test/ @guolinke @chivee @btrotta @shiyu1994
23+
tests/cpp_test/ @guolinke @chivee @btrotta @shiyu1994
24+
tests/data/ @guolinke @chivee @btrotta @shiyu1994
25+
windows/ @guolinke @chivee @btrotta @StrikerRUS @shiyu1994
2626

2727
# R code
2828
R-package/ @Laurae2 @jameslamb
2929

3030
# Python code
31-
python-package/ @StrikerRUS @chivee @wxchan @henry0312
31+
python-package/ @StrikerRUS @chivee @wxchan @henry0312 @shiyu1994
3232

3333
# Dask integration
3434
python-package/lightgbm/dask.py @jameslamb
@@ -46,15 +46,15 @@ examples/ @StrikerRUS @jameslamb @guolinke
4646

4747
# docker setup
4848
docker/ @StrikerRUS @jameslamb
49-
docker/dockerfile-cli @guolinke @chivee
49+
docker/dockerfile-cli @guolinke @chivee @shiyu1994
5050
docker/gpu/ @huanzhang12
51-
docker/dockerfile-python @StrikerRUS @chivee @wxchan @henry0312
51+
docker/dockerfile-python @StrikerRUS @chivee @wxchan @henry0312 @shiyu1994
5252
docker/dockerfile-r @Laurae2 @jameslamb
5353

5454
# GPU code
5555
docs/GPU-*.rst @huanzhang12
56-
src/treelearner/gpu_tree_learner.cpp @huanzhang12 @guolinke @chivee
57-
src/treelearner/tree_learner.cpp @huanzhang12 @guolinke @chivee
56+
src/treelearner/gpu_tree_learner.cpp @huanzhang12 @guolinke @chivee @shiyu1994
57+
src/treelearner/tree_learner.cpp @huanzhang12 @guolinke @chivee @shiyu1994
5858

5959
# JAVA code
60-
swig/ @imatiach-msft
60+
swig/ @guolinke @chivee @shiyu1994

.github/workflows/r_package.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ jobs:
6060
compiler: clang
6161
r_version: 4.0
6262
build_type: cmake
63+
- os: windows-latest
64+
task: r-package
65+
compiler: MINGW
66+
toolchain: MINGW
67+
r_version: 3.6
68+
build_type: cmake
6369
- os: windows-latest
6470
task: r-package
6571
compiler: MINGW

.github/workflows/r_solaris.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- name: Send init status
3232
if: ${{ always() }}
3333
run: |
34+
$GITHUB_WORKSPACE/.ci/set_commit_status.sh "${{ github.workflow }}" "pending" "${{ github.event.client_payload.pr_sha }}"
3435
$GITHUB_WORKSPACE/.ci/append_comment.sh \
3536
"${{ github.event.client_payload.comment_number }}" \
3637
"Workflow **${{ github.workflow }}** has been triggered! 🚀\r\n${GITHUB_SERVER_URL}/microsoft/LightGBM/actions/runs/${GITHUB_RUN_ID}"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ _Pvt_Extensions
269269
*.app
270270
/windows/LightGBM.VC.db
271271
lightgbm
272+
/testlightgbm
272273

273274
# Created by https://www.gitignore.io/api/python
274275

@@ -354,6 +355,7 @@ target/
354355

355356
# Jupyter Notebook
356357
.ipynb_checkpoints
358+
Untitled*.ipynb
357359

358360
# pyenv
359361
.python-version

CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF)
66
OPTION(USE_TIMETAG "Set to ON to output time costs" OFF)
77
OPTION(USE_CUDA "Enable CUDA-accelerated training (EXPERIMENTAL)" OFF)
88
OPTION(USE_DEBUG "Set to ON for Debug mode" OFF)
9+
OPTION(USE_SANITIZER "Use santizer flags" OFF)
10+
SET(SANITIZER_PATH "" CACHE STRING "Path to sanitizer libs")
11+
SET(ENABLED_SANITIZERS "address" "leak" "undefined" CACHE STRING
12+
"Semicolon separated list of sanitizer names. E.g 'address;leak'. Supported sanitizers are
13+
address, leak, undefined and thread.")
14+
OPTION(BUILD_CPP_TEST "Build C++ tests with Google Test" OFF)
915
OPTION(BUILD_STATIC_LIB "Build static library" OFF)
1016
OPTION(__BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF)
1117
OPTION(__INTEGRATE_OPENCL "Set to ON if building LightGBM with the OpenCL ICD Loader and its dependencies included" OFF)
@@ -26,6 +32,14 @@ endif()
2632

2733
PROJECT(lightgbm LANGUAGES C CXX)
2834

35+
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
36+
37+
#-- Sanitizer
38+
if (USE_SANITIZER)
39+
include(cmake/Sanitizer.cmake)
40+
enable_sanitizers("${ENABLED_SANITIZERS}")
41+
endif (USE_SANITIZER)
42+
2943
if(__INTEGRATE_OPENCL)
3044
set(__INTEGRATE_OPENCL ON CACHE BOOL "" FORCE)
3145
set(USE_GPU OFF CACHE BOOL "" FORCE)
@@ -451,6 +465,25 @@ if(__BUILD_FOR_R)
451465
endif(MSVC)
452466
endif(__BUILD_FOR_R)
453467

468+
#-- Google C++ tests
469+
if(BUILD_CPP_TEST)
470+
find_package(GTest CONFIG)
471+
if(NOT GTEST_FOUND)
472+
message(STATUS "Did not find Google Test in the system root. Fetching Google Test now...")
473+
include(FetchContent)
474+
FetchContent_Declare(
475+
googletest
476+
GIT_REPOSITORY https://github.com/google/googletest.git
477+
GIT_TAG release-1.10.0
478+
)
479+
FetchContent_MakeAvailable(googletest)
480+
add_library(GTest::GTest ALIAS gtest)
481+
endif()
482+
file(GLOB CPP_TEST_SOURCES tests/cpp_test/*.cpp)
483+
add_executable(testlightgbm ${CPP_TEST_SOURCES} ${SOURCES})
484+
target_link_libraries(testlightgbm PRIVATE GTest::GTest)
485+
endif()
486+
454487
install(TARGETS lightgbm _lightgbm
455488
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
456489
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib

cmake/Sanitizer.cmake

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Set appropriate compiler and linker flags for sanitizers.
2+
#
3+
# Usage of this module:
4+
# enable_sanitizers("address;leak")
5+
6+
# Add flags
7+
macro(enable_sanitizer sanitizer)
8+
if(${sanitizer} MATCHES "address")
9+
find_package(ASan REQUIRED)
10+
set(SAN_COMPILE_FLAGS "${SAN_COMPILE_FLAGS} -fsanitize=address")
11+
link_libraries(${ASan_LIBRARY})
12+
13+
elseif(${sanitizer} MATCHES "thread")
14+
find_package(TSan REQUIRED)
15+
set(SAN_COMPILE_FLAGS "${SAN_COMPILE_FLAGS} -fsanitize=thread")
16+
link_libraries(${TSan_LIBRARY})
17+
18+
elseif(${sanitizer} MATCHES "leak")
19+
find_package(LSan REQUIRED)
20+
set(SAN_COMPILE_FLAGS "${SAN_COMPILE_FLAGS} -fsanitize=leak")
21+
link_libraries(${LSan_LIBRARY})
22+
23+
elseif(${sanitizer} MATCHES "undefined")
24+
find_package(UBSan REQUIRED)
25+
set(SAN_COMPILE_FLAGS "${SAN_COMPILE_FLAGS} -fsanitize=undefined -fno-sanitize-recover=undefined")
26+
link_libraries(${UBSan_LIBRARY})
27+
28+
else()
29+
message(FATAL_ERROR "Santizer ${sanitizer} not supported.")
30+
endif()
31+
endmacro()
32+
33+
macro(enable_sanitizers SANITIZERS)
34+
# Check sanitizers compatibility.
35+
foreach ( _san ${SANITIZERS} )
36+
string(TOLOWER ${_san} _san)
37+
if (_san MATCHES "thread")
38+
if (${_use_other_sanitizers})
39+
message(FATAL_ERROR
40+
"thread sanitizer is not compatible with ${_san} sanitizer.")
41+
endif()
42+
set(_use_thread_sanitizer 1)
43+
else ()
44+
if (${_use_thread_sanitizer})
45+
message(FATAL_ERROR
46+
"${_san} sanitizer is not compatible with thread sanitizer.")
47+
endif()
48+
set(_use_other_sanitizers 1)
49+
endif()
50+
endforeach()
51+
52+
message(STATUS "Sanitizers: ${SANITIZERS}")
53+
54+
foreach( _san ${SANITIZERS} )
55+
string(TOLOWER ${_san} _san)
56+
enable_sanitizer(${_san})
57+
endforeach()
58+
message(STATUS "Sanitizers compile flags: ${SAN_COMPILE_FLAGS}")
59+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_COMPILE_FLAGS}")
60+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_COMPILE_FLAGS}")
61+
endmacro()

cmake/modules/FindASan.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(ASan_LIB_NAME ASan)
2+
3+
find_library(ASan_LIBRARY
4+
NAMES libasan.so libasan.so.5 libasan.so.4 libasan.so.3 libasan.so.2 libasan.so.1 libasan.so.0 libasan.so.0.0.0
5+
PATHS ${SANITIZER_PATH} /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib ${CMAKE_PREFIX_PATH}/lib)
6+
7+
include(FindPackageHandleStandardArgs)
8+
find_package_handle_standard_args(ASan DEFAULT_MSG
9+
ASan_LIBRARY)

cmake/modules/FindLSan.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(LSan_LIB_NAME lsan)
2+
3+
find_library(LSan_LIBRARY
4+
NAMES liblsan.so liblsan.so.0 liblsan.so.0.0.0
5+
PATHS ${SANITIZER_PATH} /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib ${CMAKE_PREFIX_PATH}/lib)
6+
7+
include(FindPackageHandleStandardArgs)
8+
find_package_handle_standard_args(LSan DEFAULT_MSG
9+
LSan_LIBRARY)

cmake/modules/FindTSan.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(TSan_LIB_NAME tsan)
2+
3+
find_library(TSan_LIBRARY
4+
NAMES libtsan.so libtsan.so.0 libtsan.so.0.0.0
5+
PATHS ${SANITIZER_PATH} /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib ${CMAKE_PREFIX_PATH}/lib)
6+
7+
include(FindPackageHandleStandardArgs)
8+
find_package_handle_standard_args(TSan DEFAULT_MSG
9+
TSan_LIBRARY)

cmake/modules/FindUBSan.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(UBSan_LIB_NAME UBSan)
2+
3+
find_library(UBSan_LIBRARY
4+
NAMES libubsan.so libubsan.so.1 libubsan.so.0 libubsan.so.0.0.0
5+
PATHS ${SANITIZER_PATH} /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib ${CMAKE_PREFIX_PATH}/lib)
6+
7+
include(FindPackageHandleStandardArgs)
8+
find_package_handle_standard_args(UBSan DEFAULT_MSG
9+
UBSan_LIBRARY)

docs/FAQ.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ You may also ping a member of the core team according to the relevant area of ex
2222

2323
- `@guolinke <https://github.com/guolinke>`__ **Guolin Ke** (C++ code / R-package / Python-package)
2424
- `@chivee <https://github.com/chivee>`__ **Qiwei Ye** (C++ code / Python-package)
25+
- `@shiyu1994 <https://github.com/shiyu1994>`__ **Yu Shi** (C++ code / Python-package)
2526
- `@btrotta <https://github.com/btrotta>`__ **Belinda Trotta** (C++ code)
2627
- `@Laurae2 <https://github.com/Laurae2>`__ **Damien Soukhavong** (R-package)
2728
- `@jameslamb <https://github.com/jameslamb>`__ **James Lamb** (R-package / Dask-package)

0 commit comments

Comments
 (0)