A video walk-through is available below, on how to set-up googleCloudRunner’s Google Console and R environment:

Manual setup

You can setup the configurations directly using the below R functions:

But it is recommended to use the environment arguments below.

Setup wizard cr_setup()

There is a setup function to help you configure the package. Get started via the commands below:

library(googleCloudRunner)
cr_setup()
#ℹ ==Welcome to googleCloudRunner setup==
#This wizard will scan your system for setup options and help you setup any that are missing.
#Hit 0 or ESC to cancel.
#
#1: Configure/check all googleCloudRunner settings
#2: Configure GCP Project Id
#3: Configure Authentication JSON file
#4: Configure Cloud Storage bucket
#5: Configure Cloud Run region
#6: Configure Cloud Scheduler build email

It will walk you through the details below. You can also use it to check your settings.

cr_setup_auth() and cr_setup_service()

You can configure authentication separately, as its usually the trickiest bit. The cr_setup_auth() function attempts to help you walk through the authentication and after running it and restarting R a couple of times you should only need to download a client ID from your project to have it all configured for you.

If you are customising things then cr_setup_service() may be useful, which lets you add common roles to the service account emails. The other setup functions call it to set things up for you, but you may want more control, or have special needs for your cloudbuild email for example, which needs roles assigned for certain services you want to build.

cr_setup_tests()

Once you get all green ticks in cr_setup() then you should be able to run the subset of the package unit tests via cr_setup_test(). Should those all complete then you should be able to run any of the functions in the package!

R Settings

R environment arguments to set:

  • Reuses environment argument GCE_AUTH_FILE from googleComputeEngineR which holds location of your service auth JSON
  • Reuses environment argument GCE_DEFAULT_PROJECT_ID from googleComputeEngineR
  • Reuses environment argument GCS_DEFAULT_BUCKET from googleCloudStorageR
  • New environment argument CR_REGION can be one of
"us-central1",
"asia-northeast1",
"europe-west1",
"us-east1"
  • New environment argument CR_BUILD_EMAIL that is a Google service email (see GCP setup)

e.g. your .Renviron should look like:

GCE_AUTH_FILE="/Users/me/auth/auth.json"
GCE_DEFAULT_PROJECT_ID="my-project"
GCS_DEFAULT_BUCKET="my-bucket"
CR_REGION="europe-west1"
CR_BUILD_EMAIL=googlecloudrunner@your-project.iam.gserviceaccount.com

This .Renviron file can be placed in the root of your project or as per what is described in ?Startup.

You can also set the above in the R scripts via:

Or authenticate via

googleAuthR::gar_service_auth("my_auth_json.com")