Unverified Commit 186711de authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[R-package] miscellaneous changes to comply with CRAN requirements (#3338)



* [R-package] update DESCRIPTION per CRAN comments

* newlines

* Apply suggestions from code review
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>

* more fixes

* update Rbuildignore

* more changes

* more changes per CRAN response

* add email

* run examples in CI

* add newest CRAN response

* add Solaris patch

* update patch

* another attempt at ifaddrs patch

* fix unnecessary comment

* update configure

* comments

* bump version

* tabs

* fix address alignment, required by cran (#3415)

* fix dataset binary file alignment

* many fixes

* fix warnings

* fix bug

* Update file_io.cpp

* Update file_io.cpp

* simplify code

* Apply suggestions from code review

* general

* remove unneeded alignment

* Update file_io.h

* int32 to byte8 alignment

* Apply suggestions from code review

* Apply suggestions from code review

* [R-package] add new copyright holder in DESCRIPTION (#3409)

* [R-package] add new copyright holder in DESCRIPTION

* fix role

* fixing conflicts

* [R-package] add new copyright holder in DESCRIPTION (#3409)

* [R-package] add new copyright holder in DESCRIPTION

* fix role

* trying to fix conflicts

* more fixes

* this will work

* update cran-comments

* simplify solaris, add more testing docs

* stuff

* remove rchck docs

* Apply suggestions from code review
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>

* remove extra use of cat()

* change solaris check

* update docs

* remove testing code

* fix warning about cleanup not having execute permissions

* fix cmake builds

* remove blank line
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>
Co-authored-by: default avatarGuolin Ke <guolin.ke@outlook.com>
parent 7a51ae04
...@@ -39,7 +39,7 @@ The columns of the \code{data.table} are: ...@@ -39,7 +39,7 @@ The columns of the \code{data.table} are:
Parse a LightGBM model json dump into a \code{data.table} structure. Parse a LightGBM model json dump into a \code{data.table} structure.
} }
\examples{ \examples{
\dontrun{ \donttest{
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -37,7 +37,7 @@ The graph represents each feature as a horizontal bar of length proportional to ...@@ -37,7 +37,7 @@ The graph represents each feature as a horizontal bar of length proportional to
Features are shown ranked in a decreasing importance order. Features are shown ranked in a decreasing importance order.
} }
\examples{ \examples{
\dontrun{ \donttest{
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -34,7 +34,7 @@ The graph represents each feature as a horizontal bar of length proportional to ...@@ -34,7 +34,7 @@ The graph represents each feature as a horizontal bar of length proportional to
contribution of a feature. Features are shown ranked in a decreasing contribution order. contribution of a feature. Features are shown ranked in a decreasing contribution order.
} }
\examples{ \examples{
\dontrun{ \donttest{
Logit <- function(x) { Logit <- function(x) {
log(x / (1.0 - x)) log(x / (1.0 - x))
} }
......
...@@ -9,6 +9,9 @@ lgb.prepare(...) ...@@ -9,6 +9,9 @@ lgb.prepare(...)
\arguments{ \arguments{
\item{...}{catch-all to match old calls} \item{...}{catch-all to match old calls}
} }
\value{
Nothing. This function always raises an exception
}
\description{ \description{
removed functions removed functions
} }
...@@ -9,6 +9,9 @@ lgb.prepare2(...) ...@@ -9,6 +9,9 @@ lgb.prepare2(...)
\arguments{ \arguments{
\item{...}{catch-all to match old calls} \item{...}{catch-all to match old calls}
} }
\value{
Nothing. This function always raises an exception
}
\description{ \description{
removed functions removed functions
} }
...@@ -9,6 +9,9 @@ lgb.prepare_rules(...) ...@@ -9,6 +9,9 @@ lgb.prepare_rules(...)
\arguments{ \arguments{
\item{...}{catch-all to match old calls} \item{...}{catch-all to match old calls}
} }
\value{
Nothing. This function always raises an exception
}
\description{ \description{
removed functions removed functions
} }
...@@ -9,6 +9,9 @@ lgb.prepare_rules2(...) ...@@ -9,6 +9,9 @@ lgb.prepare_rules2(...)
\arguments{ \arguments{
\item{...}{catch-all to match old calls} \item{...}{catch-all to match old calls}
} }
\value{
Nothing. This function always raises an exception
}
\description{ \description{
removed functions removed functions
} }
...@@ -20,7 +20,7 @@ lgb.Booster ...@@ -20,7 +20,7 @@ lgb.Booster
Save LightGBM model Save LightGBM model
} }
\examples{ \examples{
\dontrun{ \donttest{
library(lightgbm) library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
......
...@@ -132,7 +132,7 @@ Logic to train with LightGBM ...@@ -132,7 +132,7 @@ Logic to train with LightGBM
} }
\examples{ \examples{
\dontrun{ \donttest{
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -26,7 +26,7 @@ Attempts to unload LightGBM packages so you can remove objects cleanly without ...@@ -26,7 +26,7 @@ Attempts to unload LightGBM packages so you can remove objects cleanly without
apparent reason and you do not want to restart R to fix the lost object. apparent reason and you do not want to restart R to fix the lost object.
} }
\examples{ \examples{
\dontrun{ \donttest{
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -70,6 +70,9 @@ If early stopping occurs, the model will have 'best_iter' field.} ...@@ -70,6 +70,9 @@ If early stopping occurs, the model will have 'best_iter' field.}
CPU using hyper-threading to generate 2 threads per CPU core).} CPU using hyper-threading to generate 2 threads per CPU core).}
}} }}
} }
\value{
a trained \code{lgb.Booster}
}
\description{ \description{
Simple interface for training a LightGBM model. Simple interface for training a LightGBM model.
} }
......
...@@ -61,7 +61,7 @@ For regression or binary classification, it returns a vector of length \code{nro ...@@ -61,7 +61,7 @@ For regression or binary classification, it returns a vector of length \code{nro
Predicted values based on class \code{lgb.Booster} Predicted values based on class \code{lgb.Booster}
} }
\examples{ \examples{
\dontrun{ \donttest{
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -12,13 +12,13 @@ readRDS.lgb.Booster(file = "", refhook = NULL) ...@@ -12,13 +12,13 @@ readRDS.lgb.Booster(file = "", refhook = NULL)
\item{refhook}{a hook function for handling reference objects.} \item{refhook}{a hook function for handling reference objects.}
} }
\value{ \value{
\code{lgb.Booster}. \code{lgb.Booster}
} }
\description{ \description{
Attempts to load a model stored in a \code{.rds} file, using \code{\link[base]{readRDS}} Attempts to load a model stored in a \code{.rds} file, using \code{\link[base]{readRDS}}
} }
\examples{ \examples{
\dontrun{ \donttest{
library(lightgbm) library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
......
...@@ -42,7 +42,7 @@ Attempts to save a model using RDS. Has an additional parameter (\code{raw}) ...@@ -42,7 +42,7 @@ Attempts to save a model using RDS. Has an additional parameter (\code{raw})
which decides whether to save the raw model or not. which decides whether to save the raw model or not.
} }
\examples{ \examples{
\dontrun{ \donttest{
library(lightgbm) library(lightgbm)
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
......
...@@ -19,7 +19,9 @@ setinfo(dataset, ...) ...@@ -19,7 +19,9 @@ setinfo(dataset, ...)
\item{info}{the specific field of information to set} \item{info}{the specific field of information to set}
} }
\value{ \value{
passed object the dataset you passed in
the dataset you passed in
} }
\description{ \description{
Set one attribute of a \code{lgb.Dataset} Set one attribute of a \code{lgb.Dataset}
...@@ -38,7 +40,7 @@ The \code{name} field can be one of the following: ...@@ -38,7 +40,7 @@ The \code{name} field can be one of the following:
} }
} }
\examples{ \examples{
\dontrun{ \donttest{
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -17,6 +17,8 @@ slice(dataset, ...) ...@@ -17,6 +17,8 @@ slice(dataset, ...)
\item{idxset}{an integer vector of indices of rows needed} \item{idxset}{an integer vector of indices of rows needed}
} }
\value{ \value{
constructed sub dataset
constructed sub dataset constructed sub dataset
} }
\description{ \description{
...@@ -24,7 +26,7 @@ Get a new \code{lgb.Dataset} containing the specified rows of ...@@ -24,7 +26,7 @@ Get a new \code{lgb.Dataset} containing the specified rows of
original \code{lgb.Dataset} object original \code{lgb.Dataset} object
} }
\examples{ \examples{
\dontrun{ \donttest{
data(agaricus.train, package = "lightgbm") data(agaricus.train, package = "lightgbm")
train <- agaricus.train train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label) dtrain <- lgb.Dataset(train$data, label = train$label)
......
...@@ -40,6 +40,7 @@ OBJECTS = \ ...@@ -40,6 +40,7 @@ OBJECTS = \
metric/dcg_calculator.o \ metric/dcg_calculator.o \
metric/metric.o \ metric/metric.o \
objective/objective_function.o \ objective/objective_function.o \
network/ifaddrs_patch.o \
network/linker_topo.o \ network/linker_topo.o \
network/linkers_mpi.o \ network/linkers_mpi.o \
network/linkers_socket.o \ network/linkers_socket.o \
......
...@@ -41,6 +41,7 @@ OBJECTS = \ ...@@ -41,6 +41,7 @@ OBJECTS = \
metric/dcg_calculator.o \ metric/dcg_calculator.o \
metric/metric.o \ metric/metric.o \
objective/objective_function.o \ objective/objective_function.o \
network/ifaddrs_patch.o \
network/linker_topo.o \ network/linker_topo.o \
network/linkers_mpi.o \ network/linkers_mpi.o \
network/linkers_socket.o \ network/linkers_socket.o \
......
/*!
* Copyright (c) 2009, Jay Loden, Dave Daeschler, Giampaolo Rodola.
* Licensed under the BSD 3-Clause License.
* See https://github.com/giampaolo/psutil/blob/master/LICENSE
*/
#if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include "ifaddrs_patch.h"
#define MAX(x, y) ((x) > (y)?(x):(y))
#define SIZE(p) MAX((p).ss_len, sizeof(p))
static struct sockaddr *
sa_dup(struct sockaddr_storage *sa1) {
struct sockaddr *sa2;
size_t sz = sizeof(struct sockaddr_storage);
sa2 = (struct sockaddr *) calloc(1, sz);
memcpy(sa2, sa1, sz);
return(sa2);
}
void freeifaddrs(struct ifaddrs *ifp) {
if (NULL == ifp) return;
free(ifp->ifa_name);
free(ifp->ifa_addr);
free(ifp->ifa_netmask);
free(ifp->ifa_dstaddr);
freeifaddrs(ifp->ifa_next);
free(ifp);
}
int getifaddrs(struct ifaddrs **ifap) {
int sd = -1;
char *ccp, *ecp;
struct lifconf ifc;
struct lifreq *ifr;
struct lifnum lifn;
struct ifaddrs *cifa = NULL; /* current */
struct ifaddrs *pifa = NULL; /* previous */
const size_t IFREQSZ = sizeof(struct lifreq);
sd = socket(AF_INET, SOCK_STREAM, 0);
if (sd < 0)
goto error;
ifc.lifc_buf = NULL;
*ifap = NULL;
/* find how much memory to allocate for the SIOCGLIFCONF call */
lifn.lifn_family = AF_UNSPEC;
lifn.lifn_flags = 0;
if (ioctl(sd, SIOCGLIFNUM, &lifn) < 0)
goto error;
/* Sun and Apple code likes to pad the interface count here in case interfaces
* are coming up between calls */
lifn.lifn_count += 4;
ifc.lifc_family = AF_UNSPEC;
ifc.lifc_len = lifn.lifn_count * sizeof(struct lifreq);
ifc.lifc_buf = static_cast<char*>(calloc(1, ifc.lifc_len));
if (ioctl(sd, SIOCGLIFCONF, &ifc) < 0)
goto error;
ccp = reinterpret_cast<char *>(ifc.lifc_req);
ecp = ccp + ifc.lifc_len;
while (ccp < ecp) {
ifr = (struct lifreq *) ccp;
cifa = (struct ifaddrs *) calloc(1, sizeof(struct ifaddrs));
cifa->ifa_next = NULL;
cifa->ifa_name = strdup(ifr->lifr_name);
if (pifa == NULL) {
*ifap = cifa; /* first one */
} else {
pifa->ifa_next = cifa;
}
if (ioctl(sd, SIOCGLIFADDR, ifr, IFREQSZ) < 0)
goto error;
cifa->ifa_addr = sa_dup(&ifr->lifr_addr);
if (ioctl(sd, SIOCGLIFNETMASK, ifr, IFREQSZ) < 0)
goto error;
cifa->ifa_netmask = sa_dup(&ifr->lifr_addr);
cifa->ifa_flags = 0;
cifa->ifa_dstaddr = NULL;
if (0 == ioctl(sd, SIOCGLIFFLAGS, ifr)) /* optional */
cifa->ifa_flags = ifr->lifr_flags;
if (ioctl(sd, SIOCGLIFDSTADDR, ifr, IFREQSZ) < 0) {
if (0 == ioctl(sd, SIOCGLIFBRDADDR, ifr, IFREQSZ))
cifa->ifa_dstaddr = sa_dup(&ifr->lifr_addr);
} else {
cifa->ifa_dstaddr = sa_dup(&ifr->lifr_addr);
}
pifa = cifa;
ccp += IFREQSZ;
}
free(ifc.lifc_buf);
close(sd);
return 0;
error:
if (ifc.lifc_buf != NULL)
free(ifc.lifc_buf);
if (sd != -1)
close(sd);
freeifaddrs(*ifap);
return (-1);
}
#endif // (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))
/*!
* Copyright (c) 2009, Jay Loden, Dave Daeschler, Giampaolo Rodola.
* Licensed under the BSD 3-Clause License.
* See https://github.com/giampaolo/psutil/blob/master/LICENSE
*/
/*
* - https://lists.samba.org/archive/samba-technical/2009-February/063079.html
* - https://github.com/giampaolo/psutil/blob/master/psutil/arch/solaris/v10/ifaddrs.h
*/
#ifndef LIGHTGBM_NETWORK_IFADDRS_PATCH_H_
#define LIGHTGBM_NETWORK_IFADDRS_PATCH_H_
#include <sys/socket.h>
#include <net/if.h>
#undef ifa_dstaddr
#undef ifa_broadaddr
#define ifa_broadaddr ifa_dstaddr
struct ifaddrs {
struct ifaddrs *ifa_next;
char *ifa_name;
unsigned int ifa_flags;
struct sockaddr *ifa_addr;
struct sockaddr *ifa_netmask;
struct sockaddr *ifa_dstaddr;
};
extern int getifaddrs(struct ifaddrs **);
extern void freeifaddrs(struct ifaddrs *);
#endif // LIGHTGBM_NETWORK_IFADDRS_PATCH_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment