Skip to content

Commit

Permalink
Merge branch 'master' into misc/type-hints-basic-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Aug 18, 2021
2 parents 7b7ad27 + a7ff117 commit fbca9f4
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/r_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
- name: Install Git before checkout
shell: bash
run: |
apt-get update
apt-get update --allow-releaseinfo-change
apt-get install --no-install-recommends -y git
- name: Checkout repository
uses: actions/checkout@v2.3.4
Expand Down Expand Up @@ -210,7 +210,7 @@ jobs:
- name: Install Git before checkout
shell: bash
run: |
apt-get update
apt-get update --allow-releaseinfo-change
apt-get install --no-install-recommends -y git
- name: Checkout repository
uses: actions/checkout@v2.3.4
Expand Down
4 changes: 1 addition & 3 deletions R-package/R/lgb.Booster.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ Booster <- R6::R6Class(
initialize = function(params = list(),
train_set = NULL,
modelfile = NULL,
model_str = NULL,
...) {
model_str = NULL) {

# Create parameters and handle
params <- append(params, list(...))
handle <- NULL

# Attempts to create a handle for the dataset
Expand Down
36 changes: 33 additions & 3 deletions R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ lgb.Dataset.construct <- function(dataset) {
#' @title Dimensions of an \code{lgb.Dataset}
#' @description Returns a vector of numbers of rows and of columns in an \code{lgb.Dataset}.
#' @param x Object of class \code{lgb.Dataset}
#' @param ... other parameters
#' @param ... other parameters (ignored)
#'
#' @return a vector of numbers of rows and of columns
#'
Expand All @@ -853,6 +853,16 @@ lgb.Dataset.construct <- function(dataset) {
#' @export
dim.lgb.Dataset <- function(x, ...) {

additional_args <- list(...)
if (length(additional_args) > 0L) {
warning(paste0(
"dim.lgb.Dataset: Found the following passed through '...': "
, paste(names(additional_args), collapse = ", ")
, ". These are ignored. In future releases of lightgbm, this warning will become an error. "
, "See ?dim.lgb.Dataset for documentation on how to call this function."
))
}

# Check if dataset is not a dataset
if (!lgb.is.Dataset(x = x)) {
stop("dim.lgb.Dataset: input data should be an lgb.Dataset object")
Expand Down Expand Up @@ -978,7 +988,7 @@ slice.lgb.Dataset <- function(dataset, idxset, ...) {
#' @description Get one attribute of a \code{lgb.Dataset}
#' @param dataset Object of class \code{lgb.Dataset}
#' @param name the name of the information field to get (see details)
#' @param ... other parameters
#' @param ... other parameters (ignored)
#' @return info data
#'
#' @details
Expand Down Expand Up @@ -1017,6 +1027,16 @@ getinfo <- function(dataset, ...) {
#' @export
getinfo.lgb.Dataset <- function(dataset, name, ...) {

additional_args <- list(...)
if (length(additional_args) > 0L) {
warning(paste0(
"getinfo.lgb.Dataset: Found the following passed through '...': "
, paste(names(additional_args), collapse = ", ")
, ". These are ignored. In future releases of lightgbm, this warning will become an error. "
, "See ?getinfo.lgb.Dataset for documentation on how to call this function."
))
}

# Check if dataset is not a dataset
if (!lgb.is.Dataset(x = dataset)) {
stop("getinfo.lgb.Dataset: input dataset should be an lgb.Dataset object")
Expand All @@ -1032,7 +1052,7 @@ getinfo.lgb.Dataset <- function(dataset, name, ...) {
#' @param dataset Object of class \code{lgb.Dataset}
#' @param name the name of the field to get
#' @param info the specific field of information to set
#' @param ... other parameters
#' @param ... other parameters (ignored)
#' @return the dataset you passed in
#'
#' @details
Expand Down Expand Up @@ -1071,6 +1091,16 @@ setinfo <- function(dataset, ...) {
#' @export
setinfo.lgb.Dataset <- function(dataset, name, info, ...) {

additional_args <- list(...)
if (length(additional_args) > 0L) {
warning(paste0(
"setinfo.lgb.Dataset: Found the following passed through '...': "
, paste(names(additional_args), collapse = ", ")
, ". These are ignored. In future releases of lightgbm, this warning will become an error. "
, "See ?setinfo.lgb.Dataset for documentation on how to call this function."
))
}

if (!lgb.is.Dataset(x = dataset)) {
stop("setinfo.lgb.Dataset: input dataset should be an lgb.Dataset object")
}
Expand Down
13 changes: 12 additions & 1 deletion R-package/R/lgb.cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ CVBooster <- R6::R6Class(
#' not the number of threads (most CPU using hyper-threading to generate 2 threads
#' per CPU core).}
#' }
#' NOTE: As of v3.3.0, use of \code{...} is deprecated. Add parameters to \code{params} directly.
#' @inheritSection lgb_shared_params Early Stopping
#' @return a trained model \code{lgb.CVBooster}.
#'
Expand Down Expand Up @@ -108,13 +109,23 @@ lgb.cv <- function(params = list()
}

# Setup temporary variables
params <- append(params, list(...))
additional_params <- list(...)
params <- append(params, additional_params)
params$verbose <- verbose
params <- lgb.check.obj(params = params, obj = obj)
params <- lgb.check.eval(params = params, eval = eval)
fobj <- NULL
eval_functions <- list(NULL)

if (length(additional_params) > 0L) {
warning(paste0(
"lgb.cv: Found the following passed through '...': "
, paste(names(additional_params), collapse = ", ")
, ". These will be used, but in future releases of lightgbm, this warning will become an error. "
, "Add these to 'params' instead. See ?lgb.cv for documentation on how to call this function."
))
}

# set some parameters, resolving the way they were passed in with other parameters
# in `params`.
# this ensures that the model stored with Booster$save() correctly represents
Expand Down
10 changes: 10 additions & 0 deletions R-package/R/lgb.train.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#' not the number of threads (most CPU using hyper-threading to generate 2 threads
#' per CPU core).}
#' }
#' NOTE: As of v3.3.0, use of \code{...} is deprecated. Add parameters to \code{params} directly.
#' @inheritSection lgb_shared_params Early Stopping
#' @return a trained booster model \code{lgb.Booster}.
#'
Expand Down Expand Up @@ -91,6 +92,15 @@ lgb.train <- function(params = list(),
fobj <- NULL
eval_functions <- list(NULL)

if (length(additional_params) > 0L) {
warning(paste0(
"lgb.train: Found the following passed through '...': "
, paste(names(additional_params), collapse = ", ")
, ". These will be used, but in future releases of lightgbm, this warning will become an error. "
, "Add these to 'params' instead. See ?lgb.train for documentation on how to call this function."
))
}

# set some parameters, resolving the way they were passed in with other parameters
# in `params`.
# this ensures that the model stored with Booster$save() correctly represents
Expand Down
28 changes: 13 additions & 15 deletions R-package/configure
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,17 @@ if test -z "${R_HOME}"; then
exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CXX=`"${R_HOME}/bin/R" CMD config CXX11`
CXX11=`"${R_HOME}/bin/R" CMD config CXX11`
CXX11STD=`"${R_HOME}/bin/R" CMD config CXX11STD`
CXX="${CXX11} ${CXX11STD}"
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXX11FLAGS`
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu


# LightGBM-specific flags
LGB_CPPFLAGS=""
Expand All @@ -1712,12 +1722,6 @@ LGB_CPPFLAGS="${LGB_CPPFLAGS} -DEIGEN_MPL2_ONLY"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether MM_PREFETCH works" >&5
$as_echo_n "checking whether MM_PREFETCH works... " >&6; }
ac_mmprefetch=no
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand All @@ -1739,7 +1743,7 @@ main ()
_ACEOF
${CXX} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mmprefetch=yes
${CXX} ${CPPFLAGS} ${CXXFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mmprefetch=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_mmprefetch}" >&5
$as_echo "${ac_mmprefetch}" >&6; }
if test "${ac_mmprefetch}" = yes; then
Expand All @@ -1753,12 +1757,6 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether MM_MALLOC works" >&5
$as_echo_n "checking whether MM_MALLOC works... " >&6; }
ac_mm_malloc=no
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand All @@ -1780,7 +1778,7 @@ main ()
_ACEOF
${CXX} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc=yes
${CXX} ${CPPFLAGS} ${CXXFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_mm_malloc}" >&5
$as_echo "${ac_mm_malloc}" >&6; }
if test "${ac_mm_malloc}" = yes; then
Expand Down
13 changes: 8 additions & 5 deletions R-package/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ if test -z "${R_HOME}"; then
exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CXX=`"${R_HOME}/bin/R" CMD config CXX11`
CXX11=`"${R_HOME}/bin/R" CMD config CXX11`
CXX11STD=`"${R_HOME}/bin/R" CMD config CXX11STD`
CXX="${CXX11} ${CXX11STD}"
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXX11FLAGS`
AC_LANG(C++)

# LightGBM-specific flags
LGB_CPPFLAGS=""
Expand All @@ -38,7 +43,6 @@ LGB_CPPFLAGS="${LGB_CPPFLAGS} -DEIGEN_MPL2_ONLY"

AC_MSG_CHECKING([whether MM_PREFETCH works])
ac_mmprefetch=no
AC_LANG(C++)
AC_LANG_CONFTEST(
[
AC_LANG_PROGRAM(
Expand All @@ -53,7 +57,7 @@ AC_LANG_CONFTEST(
)
]
)
${CXX} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mmprefetch=yes
${CXX} ${CPPFLAGS} ${CXXFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mmprefetch=yes
AC_MSG_RESULT([${ac_mmprefetch}])
if test "${ac_mmprefetch}" = yes; then
LGB_CPPFLAGS+=" -DMM_PREFETCH=1"
Expand All @@ -65,7 +69,6 @@ fi

AC_MSG_CHECKING([whether MM_MALLOC works])
ac_mm_malloc=no
AC_LANG(C++)
AC_LANG_CONFTEST(
[
AC_LANG_PROGRAM(
Expand All @@ -80,7 +83,7 @@ AC_LANG_CONFTEST(
)
]
)
${CXX} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc=yes
${CXX} ${CPPFLAGS} ${CXXFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc=yes
AC_MSG_RESULT([${ac_mm_malloc}])
if test "${ac_mm_malloc}" = yes; then
LGB_CPPFLAGS+=" -DMM_MALLOC=1"
Expand Down
2 changes: 1 addition & 1 deletion R-package/man/dim.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion R-package/man/getinfo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion R-package/man/lgb.cv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion R-package/man/lgb.train.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion R-package/man/setinfo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions docs/Installation-Guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ On Linux LightGBM can be built using **CMake** and **gcc** or **Clang**.
**Note**: glibc >= 2.14 is required.

**Note**: In some rare cases you may need to install OpenMP runtime library separately (use your package manager and search for ``lib[g|i]omp`` for doing this).

Also, you may want to read `gcc Tips <./gcc-Tips.rst>`__.

macOS
Expand Down Expand Up @@ -437,6 +439,8 @@ On Linux an MPI version of LightGBM can be built using **Open MPI**, **CMake** a
**Note**: glibc >= 2.14 is required.

**Note**: In some rare cases you may need to install OpenMP runtime library separately (use your package manager and search for ``lib[g|i]omp`` for doing this).

macOS
^^^^^

Expand Down Expand Up @@ -544,6 +548,10 @@ To build LightGBM GPU version, run the following commands:
# cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ ..
make -j4
**Note**: glibc >= 2.14 is required.

**Note**: In some rare cases you may need to install OpenMP runtime library separately (use your package manager and search for ``lib[g|i]omp`` for doing this).

Windows
^^^^^^^

Expand Down Expand Up @@ -626,6 +634,10 @@ To build LightGBM CUDA version, run the following commands:
cmake -DUSE_CUDA=1 ..
make -j4
**Note**: glibc >= 2.14 is required.

**Note**: In some rare cases you may need to install OpenMP runtime library separately (use your package manager and search for ``lib[g|i]omp`` for doing this).

Build HDFS Version
~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -655,6 +667,10 @@ On Linux a HDFS version of LightGBM can be built using **CMake** and **gcc**.
# ..
make -j4
**Note**: glibc >= 2.14 is required.

**Note**: In some rare cases you may need to install OpenMP runtime library separately (use your package manager and search for ``lib[g|i]omp`` for doing this).

Build Java Wrapper
~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -730,6 +746,10 @@ On Linux a Java wrapper of LightGBM can be built using **Java**, **SWIG**, **CMa
cmake -DUSE_SWIG=ON ..
make -j4
**Note**: glibc >= 2.14 is required.

**Note**: In some rare cases you may need to install OpenMP runtime library separately (use your package manager and search for ``lib[g|i]omp`` for doing this).

macOS
^^^^^

Expand Down
Loading

0 comments on commit fbca9f4

Please sign in to comment.