diff --git a/DESCRIPTION b/DESCRIPTION index e9c6a6c1..c3fe44c9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -5,7 +5,8 @@ Title: R Scripts in the Google Cloud via Cloud Run, Cloud Build Version: 0.1.1 Authors@R: c(person("Mark", "Edmondson", email = "r@sunholo.com", role = c("aut", "cre"), - comment = c(ORCID = "0000-0002-8434-3881"))) + comment = c(ORCID = "0000-0002-8434-3881")), + person("Sunholo Ltd", role = "cph")) Description: Tools to easily enable R scripts in the Google Cloud Platform. Utilise cloud services such as Cloud Run for R over HTTP, Cloud Build for Continuous Delivery diff --git a/NEWS.md b/NEWS.md index 7496dc11..c9efbf88 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,3 @@ -# googleCloudRunner 0.1.0 +# googleCloudRunner 0.1.1 * Initial release diff --git a/vignettes/cloudbuild.Rmd b/vignettes/cloudbuild.Rmd index 0c75c8d5..ab64721c 100644 --- a/vignettes/cloudbuild.Rmd +++ b/vignettes/cloudbuild.Rmd @@ -79,7 +79,7 @@ All cloudbuilds are launched in a serverless environment with a default director Cloud Build sources are specified by the `source` argument. -A source can be a [Cloud Source Repository](https://cloud.google.com/source-repositories/) (perhaps mirrored from GitHub) or a [Cloud Storage](https://cloud.google.com/storage/) bucket containg the code/data you want to operate on. An example of specifying both is below: +A source can be a [Cloud Source Repository](https://cloud.google.com/source-repositories/) (perhaps mirrored from GitHub) or a [Cloud Storage](https://cloud.google.com/storage/) bucket containing the code/data you want to operate on. An example of specifying both is below: ```r gcs_source <- cr_build_source( @@ -116,34 +116,7 @@ Cloud Builds can use reserved macros and variables to help with deployments in a * $REVISION_ID or $COMMIT_SHA: the commit SHA specified by RepoSource or resolved from the specified branch or tag. * $SHORT_SHA: first 7 characters of $REVISION_ID or $COMMIT_SHA. -Custom macros can also be configured in the web UI, starting with _$ e.g. $_MY_CUSTOM_MACRO - -## Build Artifacts - -You may have some useful files or data after your buildsteps that you want to use later. You can specify these files as **artifacts** that will be uploaded to a Google Cloud Storage bucket after the build finishes. A helper function `cr_build_artifacts()` will take your build object and download the files to your local directory via `googleCloudStorageR` - - -```r -r <- "write.csv(mtcars,file = 'artifact.csv')" -ba <- cr_build_yaml( - steps = cr_buildstep_r(r), - artifacts = cr_build_yaml_artifact('artifact.csv') - ) - -build <- cr_build(ba) -built <- cr_build_wait(build) - -cr_build_artifacts(built) -# 2019-12-22 12:36:10 -- Saved artifact.csv to artifact.csv (1.7 Kb) - -read.csv("artifact.csv") -# X mpg cyl disp hp drat wt qsec vs am gear carb -#1 Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 -#2 Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 -#3 Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 -#4 Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 -# ... etc ... -``` +Custom macros can also be configured, starting with _$ e.g. $_MY_CUSTOM_MACRO ## Creating cloudbuild.yml build steps @@ -201,6 +174,33 @@ cr_build_yaml( images = "gcr.io/my-project/my-image") ``` +## Build Artifacts + +You may have some useful files or data after your buildsteps that you want to use later. You can specify these files as **artifacts** that will be uploaded to a Google Cloud Storage bucket after the build finishes. A helper function `cr_build_artifacts()` will take your build object and download the files to your local directory via `googleCloudStorageR` + + +```r +r <- "write.csv(mtcars,file = 'artifact.csv')" +ba <- cr_build_yaml( + steps = cr_buildstep_r(r), + artifacts = cr_build_yaml_artifact('artifact.csv') + ) + +build <- cr_build(ba) +built <- cr_build_wait(build) + +cr_build_artifacts(built) +# 2019-12-22 12:36:10 -- Saved artifact.csv to artifact.csv (1.7 Kb) + +read.csv("artifact.csv") +# X mpg cyl disp hp drat wt qsec vs am gear carb +#1 Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 +#2 Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 +#3 Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 +#4 Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 +# ... etc ... +``` + ### RStudio Gadget - build Docker If you are using RStudio, installing the library will enable an [RStudio Addin](https://rstudio.github.io/rstudioaddins/) that can be called after you have setup the library as per the setup page. diff --git a/vignettes/usecases.Rmd b/vignettes/usecases.Rmd index 88c22add..681b66b0 100644 --- a/vignettes/usecases.Rmd +++ b/vignettes/usecases.Rmd @@ -318,5 +318,5 @@ schedule_me <- cr_build_schedule_http(built) cr_schedule("polygot-example", "15 8 * * *", httpTarget = schedule_me) ``` -An example of that cloudbuild.yaml is on GitHub [here](https://raw.githubusercontent.com/MarkEdmondson1234/googleCloudRunner/master/inst/polygot/cloudbuild.yaml). +An example of the cloudbuild.yaml is on GitHub [here](https://raw.githubusercontent.com/MarkEdmondson1234/googleCloudRunner/master/inst/polygot/cloudbuild.yaml).