[SPARK-21149][R] Add job description API for R

## What changes were proposed in this pull request?

Extend `setJobDescription` to SparkR API.

## How was this patch tested?

It looks difficult to add a test. Manually tested as below:

```r
df <- createDataFrame(iris)
count(df)
setJobDescription("This is an example job.")
count(df)
```

prints ...

![2017-06-22 12 05 49](https://user-images.githubusercontent.com/6477701/27415670-2a649936-5743-11e7-8e95-312f1cd103af.png)

Author: hyukjinkwon <gurwls223@gmail.com>

Closes #18382 from HyukjinKwon/SPARK-21149.
This commit is contained in:
hyukjinkwon 2017-06-23 09:59:24 -07:00 committed by Felix Cheung
parent f3dea60793
commit 07479b3cfb
3 changed files with 20 additions and 1 deletions

View file

@ -75,7 +75,8 @@ exportMethods("glm",
# Job group lifecycle management methods
export("setJobGroup",
"clearJobGroup",
"cancelJobGroup")
"cancelJobGroup",
"setJobDescription")
# Export Utility methods
export("setLogLevel")

View file

@ -535,6 +535,23 @@ cancelJobGroup <- function(sc, groupId) {
}
}
#' Set a human readable description of the current job.
#'
#' Set a description that is shown as a job description in UI.
#'
#' @param value The job description of the current job.
#' @rdname setJobDescription
#' @name setJobDescription
#' @examples
#'\dontrun{
#' setJobDescription("This is an example job.")
#'}
#' @note setJobDescription since 2.3.0
setJobDescription <- function(value) {
sc <- getSparkContext()
invisible(callJMethod(sc, "setJobDescription", value))
}
sparkConfToSubmitOps <- new.env()
sparkConfToSubmitOps[["spark.driver.memory"]] <- "--driver-memory"
sparkConfToSubmitOps[["spark.driver.extraClassPath"]] <- "--driver-class-path"

View file

@ -100,6 +100,7 @@ test_that("job group functions can be called", {
setJobGroup("groupId", "job description", TRUE)
cancelJobGroup("groupId")
clearJobGroup()
setJobDescription("job description")
suppressWarnings(setJobGroup(sc, "groupId", "job description", TRUE))
suppressWarnings(cancelJobGroup(sc, "groupId"))