Place within your .Rprofile
to load and save your session data automatically
gcs_first(bucket = Sys.getenv("GCS_SESSION_BUCKET")) gcs_last(bucket = Sys.getenv("GCS_SESSION_BUCKET"))
bucket | The bucket holding your session data. See Details. |
---|
The folder you want to save to Google Cloud Storage will also need to have a yaml file called _gcssave.yaml
in the root of the directory. It can hold the following arguments:
[Required] bucket
- the GCS bucket to save to
[Optional] loaddir
- if the folder name is different to the current, where to load the R session from
[Optional] pattern
- a regex of what files to save at the end of the session
[Optional] load_on_startup
- if FALSE
will not attempt to load on startup
The bucket name is also set via the environment arg GCE_SESSION_BUCKET
. The yaml bucket name will take precedence if both are set.
The folder is named on GCS the full working path to the working directory e.g. /Users/mark/dev/your-r-project
which is what is looked for on startup. If you create a new R project with the same filepath and bucket as an existing saved set, the files will download automatically when you load R from that folder (when starting an RStudio project).
If you load from a different filepath (e.g. with loadir
set in yaml), when you exit and save the files will be saved under your new present working directory.
Files with the same name will not be overwritten. If you want them to be, delete or rename them then reload the R session.
This function does not act like git, or intended as a replacement - its main use is imagined to be for using RStudio Server within disposable Docker containers on Google Cloud Engine (e.g. via googleComputeEngineR
)
For authentication for GCS,
the easiest way is to make sure your authentication file is
available in environment file GCS_AUTH_FILE
,
or if on Google Compute Engine it will reuse the Google Cloud authentication
via gar_gce_auth
gcs_save_all and gcs_load_all that these functions call
gcs_save_all and gcs_load_all that these functions call
if (FALSE) { .First <- function(){ googleCloudStorageR::gcs_first() } .Last <- function(){ googleCloudStorageR::gcs_last() } }