Skip to content

Commit

Permalink
cran feedback 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEdmondson1234 committed Jan 25, 2020
1 parent 7d193f1 commit 8116215
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 32 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]",
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 <https://cloud.run> for R over HTTP,
Cloud Build <https://cloud.google.com/cloud-build/> for Continuous Delivery
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# googleCloudRunner 0.1.0
# googleCloudRunner 0.1.1

* Initial release
58 changes: 29 additions & 29 deletions vignettes/cloudbuild.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion vignettes/usecases.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 8116215

Please sign in to comment.