Will create a build to run an R script in Cloud Build with an optional schedule from Cloud Scheduler

cr_deploy_r(
  r,
  schedule = NULL,
  source = NULL,
  run_name = NULL,
  r_image = "rocker/verse",
  pre_steps = NULL,
  post_steps = NULL,
  timeout = 600L,
  ...,
  email = cr_email_get(),
  region = cr_region_get(),
  projectId = cr_project_get(),
  launch_browser = interactive()
)

Arguments

r

R code to run or a file containing R code ending with .R, or the gs:// location on Cloud Storage of the R file you want to run

schedule

A cron schedule e.g. "15 5 * * *"

source

A Source object specifying the location of the source files to build, usually created by cr_build_source

run_name

What name the R code will identify itself as. If NULL one is autogenerated.

r_image

The R docker environment executing the R code

pre_steps

Other cr_buildstep to run before the R code executes

post_steps

Other cr_buildstep to run after the R code executes

timeout

Amount of time that this build should be allowed to run, to second

...

Arguments passed on to cr_buildstep_r

name

The docker image that will run the R code, usually from rocker-project.org

r_source

Whether the R code will be from a runtime file within the source or at build time copying over from a local R file in your session

escape_dollar

Default TRUE. This will turn $ into $$ within the script to avoid them being recognised as Cloud Build variables. Turn this off if you want that behaviour (e.g. my_project="$PROJECT_ID")

prefix

prefixed to name - set to "" to suppress. Will be suppressed if name starts with gcr.io

email

The email that will authenticate the job set via cr_email_set

region

The region usually set with cr_region_set

projectId

ID of the project

launch_browser

Whether to launch the logs URL in a browser once deployed

Value

If scheduling then a Job, if building immediately then a Build

Details

If schedule=NULL then the R script will be run immediately on Cloud Build via cr_build.

If schedule carries a cron job string (e.g. "15 5 * * *") then the build will be scheduled via Cloud Scheduler to run as described in cr_build_schedule_http

The R script will execute within the root directory of which Source you supply, usually created via cr_build_source. Bear in mind if the source changes then the code scheduled may need updating.

The r_image dictates what R libraries the R environment executing the code of 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 cr_deploy_docker)

See also

If you want to run R code upon certain events like GitHub pushes, look at cr_buildtrigger

Other Deployment functions: cr_deploy_docker_trigger(), cr_deploy_docker(), cr_deploy_packagetests(), cr_deploy_pkgdown(), cr_deploy_run_website(), cr_deploy_run()

Examples

r_lines <- c("list.files()", "library(dplyr)", "mtcars %>% select(mpg)", "sessionInfo()") source <- cr_build_source(RepoSource("googleCloudStorageR", branchName = "master")) if (FALSE) { cr_project_set("my-project") cr_region_set("europe-west1") cr_email_set("123456@projectid.iam.gserviceaccount.com") # check the script runs ok cr_deploy_r(r_lines, source = source) # schedule the script cr_deploy_r(r_lines, schedule = "15 21 * * *", source = source) }