Repository: spark Updated Branches: refs/heads/master 3da3d7635 -> 2ca5aae47
[SPARK-22281][SPARKR] Handle R method breaking signature changes ## What changes were proposed in this pull request? This is to fix the code for the latest R changes in R-devel, when running CRAN check ``` checking for code/documentation mismatches ... WARNING Codoc mismatches from documentation object 'attach': attach Code: function(what, pos = 2L, name = deparse(substitute(what), backtick = FALSE), warn.conflicts = TRUE) Docs: function(what, pos = 2L, name = deparse(substitute(what)), warn.conflicts = TRUE) Mismatches in argument default values: Name: 'name' Code: deparse(substitute(what), backtick = FALSE) Docs: deparse(substitute(what)) Codoc mismatches from documentation object 'glm': glm Code: function(formula, family = gaussian, data, weights, subset, na.action, start = NULL, etastart, mustart, offset, control = list(...), model = TRUE, method = "glm.fit", x = FALSE, y = TRUE, singular.ok = TRUE, contrasts = NULL, ...) Docs: function(formula, family = gaussian, data, weights, subset, na.action, start = NULL, etastart, mustart, offset, control = list(...), model = TRUE, method = "glm.fit", x = FALSE, y = TRUE, contrasts = NULL, ...) Argument names in code not in docs: singular.ok Mismatches in argument names: Position: 16 Code: singular.ok Docs: contrasts Position: 17 Code: contrasts Docs: ... ``` With attach, it's pulling in the function definition from base::attach. We need to disable that but we would still need a function signature for roxygen2 to build with. With glm it's pulling in the function definition (ie. "usage") from the stats::glm function. Since this is "compiled in" when we build the source package into the .Rd file, when it changes at runtime or in CRAN check it won't match the latest signature. The solution is not to pull in from stats::glm since there isn't much value in doing that (none of the param we actually use, the ones we do use we have explicitly documented them) Also with attach we are changing to call dynamically. ## How was this patch tested? Manually. - [x] check documentation output - yes - [x] check help `?attach` `?glm` - yes - [x] check on other platforms, r-hub, on r-devel etc.. Author: Felix Cheung <felixcheun...@hotmail.com> Closes #19557 from felixcheung/rattachglmdocerror. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2ca5aae4 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2ca5aae4 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2ca5aae4 Branch: refs/heads/master Commit: 2ca5aae47a25dc6bc9e333fb592025ff14824501 Parents: 3da3d76 Author: Felix Cheung <felixcheun...@hotmail.com> Authored: Tue Nov 7 21:02:14 2017 -0800 Committer: Felix Cheung <felixche...@apache.org> Committed: Tue Nov 7 21:02:14 2017 -0800 ---------------------------------------------------------------------- R/pkg/R/DataFrame.R | 11 +++++++---- R/pkg/R/generics.R | 10 ++++------ R/pkg/R/mllib_regression.R | 1 + R/run-tests.sh | 6 +++--- 4 files changed, 15 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/2ca5aae4/R/pkg/R/DataFrame.R ---------------------------------------------------------------------- diff --git a/R/pkg/R/DataFrame.R b/R/pkg/R/DataFrame.R index aaa3349..763c8d2 100644 --- a/R/pkg/R/DataFrame.R +++ b/R/pkg/R/DataFrame.R @@ -3236,7 +3236,7 @@ setMethod("as.data.frame", #' #' @family SparkDataFrame functions #' @rdname attach -#' @aliases attach,SparkDataFrame-method +#' @aliases attach attach,SparkDataFrame-method #' @param what (SparkDataFrame) The SparkDataFrame to attach #' @param pos (integer) Specify position in search() where to attach. #' @param name (character) Name to use for the attached SparkDataFrame. Names @@ -3252,9 +3252,12 @@ setMethod("as.data.frame", #' @note attach since 1.6.0 setMethod("attach", signature(what = "SparkDataFrame"), - function(what, pos = 2, name = deparse(substitute(what)), warn.conflicts = TRUE) { - newEnv <- assignNewEnv(what) - attach(newEnv, pos = pos, name = name, warn.conflicts = warn.conflicts) + function(what, pos = 2L, name = deparse(substitute(what), backtick = FALSE), + warn.conflicts = TRUE) { + args <- as.list(environment()) # capture all parameters - this must be the first line + newEnv <- assignNewEnv(args$what) + args$what <- newEnv + do.call(attach, args) }) #' Evaluate a R expression in an environment constructed from a SparkDataFrame http://git-wip-us.apache.org/repos/asf/spark/blob/2ca5aae4/R/pkg/R/generics.R ---------------------------------------------------------------------- diff --git a/R/pkg/R/generics.R b/R/pkg/R/generics.R index 4e42748..8312d41 100644 --- a/R/pkg/R/generics.R +++ b/R/pkg/R/generics.R @@ -409,7 +409,8 @@ setGeneric("as.data.frame", standardGeneric("as.data.frame") }) -#' @rdname attach +# Do not document the generic because of signature changes across R versions +#' @noRd #' @export setGeneric("attach") @@ -1569,12 +1570,9 @@ setGeneric("year", function(x) { standardGeneric("year") }) #' @export setGeneric("fitted") -#' @param x,y For \code{glm}: logical values indicating whether the response vector -#' and model matrix used in the fitting process should be returned as -#' components of the returned value. -#' @inheritParams stats::glm -#' @rdname glm +# Do not carry stats::glm usage and param here, and do not document the generic #' @export +#' @noRd setGeneric("glm") #' @param object a fitted ML model object. http://git-wip-us.apache.org/repos/asf/spark/blob/2ca5aae4/R/pkg/R/mllib_regression.R ---------------------------------------------------------------------- diff --git a/R/pkg/R/mllib_regression.R b/R/pkg/R/mllib_regression.R index f734a08..545be5e 100644 --- a/R/pkg/R/mllib_regression.R +++ b/R/pkg/R/mllib_regression.R @@ -210,6 +210,7 @@ setMethod("spark.glm", signature(data = "SparkDataFrame", formula = "formula"), #' 1.0. #' @return \code{glm} returns a fitted generalized linear model. #' @rdname glm +#' @aliases glm #' @export #' @examples #' \dontrun{ http://git-wip-us.apache.org/repos/asf/spark/blob/2ca5aae4/R/run-tests.sh ---------------------------------------------------------------------- diff --git a/R/run-tests.sh b/R/run-tests.sh index f38c86e..86bd8aa 100755 --- a/R/run-tests.sh +++ b/R/run-tests.sh @@ -47,10 +47,10 @@ if [[ $FAILED != 0 || $NUM_TEST_WARNING != 0 ]]; then echo -en "\033[0m" # No color exit -1 else - # We have 2 NOTEs for RoxygenNote, attach(); and one in Jenkins only "No repository set" + # We have 2 NOTEs: for RoxygenNote and one in Jenkins only "No repository set" # For non-latest version branches, one WARNING for package version - if [[ ($NUM_CRAN_WARNING != 0 || $NUM_CRAN_ERROR != 0 || $NUM_CRAN_NOTES -gt 3) && - ($HAS_PACKAGE_VERSION_WARN != 1 || $NUM_CRAN_WARNING != 1 || $NUM_CRAN_ERROR != 0 || $NUM_CRAN_NOTES -gt 2) ]]; then + if [[ ($NUM_CRAN_WARNING != 0 || $NUM_CRAN_ERROR != 0 || $NUM_CRAN_NOTES -gt 2) && + ($HAS_PACKAGE_VERSION_WARN != 1 || $NUM_CRAN_WARNING != 1 || $NUM_CRAN_ERROR != 0 || $NUM_CRAN_NOTES -gt 1) ]]; then cat $CRAN_CHECK_LOG_FILE echo -en "\033[31m" # Red echo "Had CRAN check errors; see logs." --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org