Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEdmondson1234 committed Dec 6, 2019
1 parent 8f42b20 commit 5a43dd3
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 10 deletions.
12 changes: 6 additions & 6 deletions R/deploy.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#' @inheritParams cr_build_schedule_http
#' @param r_image The R docker environment exectuting the R code
#' @param run_name What name the R code will identify itself as. If \code{NULL} one is autogenerated.
#' @param pre_steps Other \link{cr_buildsteps} to run before the R code executes
#' @param post_steps Other \link{cr_buildsteps} to run after the R code executes
#' @param pre_steps Other \link{cr_buildstep} to run before the R code executes
#' @param post_steps Other \link{cr_buildstep} to run after the R code executes
#' @details
#'
#' If \code{schedule=NULL} then the R script will be run immediatly on Cloud Build via \link{cr_build}.
Expand All @@ -21,7 +21,7 @@
#' The \code{r_image} dictates what R libraries the R environment executing the code of \code{r} will have, via the underlying Docker container usually supplied by rocker-project.org. If you want custom R libraries beyond the default, create a docker container with those R libraries installed (perhaps via \link{cr_deploy_docker})
#'
#' @return If scheduling then a \link{Job}, if building immediately then a \link{Build}
#'
#' @family Deployment functions
#' @export
#' @examples
#'
Expand Down Expand Up @@ -109,7 +109,7 @@ cr_deploy_r <- function(r,
#' @param bucket The Cloud Storage bucket that will hold the code
#' @inheritParams cr_buildstep_docker
#' @inheritParams cr_build
#'
#' @family Deployment functions
#' @details
#'
#' The entrypoint for CloudRun will be via a plumber script called api.R - this should be included in your local folder to deploy.
Expand All @@ -120,7 +120,6 @@ cr_deploy_r <- function(r,
#' It will call \link{cr_deploy_docker} to create the image to deploy on Cloud Run
#'
#' @export
#'
#' @examples
#'
#' \dontrun{
Expand Down Expand Up @@ -196,6 +195,7 @@ make_image_name <- function(name, projectId){
#' @inheritParams cr_buildstep_docker
#' @inheritParams cr_build
#' @export
#' @family Deployment functions
#' @examples
#'
#' \dontrun{
Expand Down Expand Up @@ -268,7 +268,7 @@ cr_deploy_docker <- function(local,
#' The git ssh keys need to be deployed to Google KMS for the deployment of the website - see \link{cr_buildstep_git} - this only needs to be done once per Git account. You then need to commit the encrypted ssh key (by default called \code{id_rsa.enc})
#'
#' @seealso Create your own custom deployment using \link{cr_buildstep_pkgdown} which this function uses with some defaults
#'
#' @family Deployment functions
#' @export
#' @examples
#'
Expand Down
7 changes: 7 additions & 0 deletions R/print_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ print.gar_Build <- function(x, ...){
cat0("buildId: ", x$id)
cat0("status: ", x$status)
cat0("logUrl: ", x$logUrl)
cat0("timeout: ", x$timeout)
cat0("logsBucket: ", x$logsBucket)
cat0("options: ", x$options)
cat0("substitutions: ", x$substitution)
cat0("tags: ", x$tags)
cat0("secrets: ", x$secrets)
cat0("artifacts: ", x$artifacts)
if(!is.null(x$steps)){
cat("steps:\n")
if(is.data.frame(x$steps)){
Expand Down
5 changes: 5 additions & 0 deletions man/cr_deploy_docker.Rd

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

4 changes: 4 additions & 0 deletions man/cr_deploy_pkgdown.Rd

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

10 changes: 8 additions & 2 deletions man/cr_deploy_r.Rd

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

6 changes: 6 additions & 0 deletions man/cr_deploy_run.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-build.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ test_that("Building Build Objects", {
projectId = "dummy-project")
expect_true(googleCloudRunner:::is.gar_Build(bq))
expect_equal(bq$images, "gcr.io/my-project/demo")
expect_equal(bq$timeout, 10)
expect_equal(bq$timeout, "10s")
expect_equal(bq$steps[[1]]$name, "gcr.io/cloud-builders/docker")
expect_equal(bq$steps[[2]]$name, "alpine")
expect_equal(bq$source$storageSource$bucket, "gs://my-bucket")

bq2 <- cr_build_make(yaml = yaml,
source = my_repo_source,
timeout = 11,
timeout = "11s",
images = "gcr.io/my-project/demo",
projectId = "dummy-project")
expect_true(googleCloudRunner:::is.gar_Build(bq2))
Expand Down
12 changes: 12 additions & 0 deletions vignettes/cloudscheduler.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,19 @@ cr_deploy_r(r_lines, source = source)

# schedule the script once its working
cr_deploy_r(r_lines, schedule = "15 21 * * *", source = source)
```

You may want to customise the R docker image you run code from - in this case build your docker image first with your R libraries installed, then specify that image in your R deployment:

```r
cr_deploy_docker("my_folder_with_dockerfile",
image_name = "gcr.io/my-project/my-image",
tag = "dev")

cr_deploy_r(r_lines,
schedule = "15 21 * * *",
source = source,
r_image = "gcr.io/my-project/my-image:dev")
```

## Build and schedule an R script (custom)
Expand Down

0 comments on commit 5a43dd3

Please sign in to comment.