MarkEdmondson1234 / googleCloudRunner

Easy R scripts on Google Cloud Platform via Cloud Run, Cloud Build and Cloud Scheduler
https://code.markedmondson.me/googleCloudRunner/
Other
81 stars 26 forks source link

How to deal with uploading from same folder and avoiding setwd() #151

Closed MarkEdmondson1234 closed 2 years ago

MarkEdmondson1234 commented 2 years ago

The good practice message for code here within cr_build_upload_gcs

avoid calling setwd(), it changes the global environment.

https://github.com/MarkEdmondson1234/googleCloudRunner/blob/ed6b9de67025fe5f2ce162dbd2a3d6151a224866/R/build_sources.R#L264-L288

Its done to preserve file structure, but see if a way to avoid setwd()

MarkEdmondson1234 commented 2 years ago

I had to revert this code introduced in https://github.com/MarkEdmondson1234/googleCloudRunner/pull/122 as it ended up deleting my test directory - the unlink() should only ever be directed at temporary files.

MarkEdmondson1234 commented 2 years ago

I ended up using withr::with_folder()