MarkEdmondson1234 / googleCloudRunner

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

Not sure if gmailr is compatible with googleCloudRunner #204

Open sommerhd-royals opened 1 year ago

sommerhd-royals commented 1 year ago

Hi Mark,

Your work with googleCloudRunner is remarkable, first of all. With that out of the way, I have successfully been able to run R scripts in Google Cloud with Cloud Build (using the checklist at https://medium.com/@damiencaillet/automate-r-code-in-the-cloud-89266910cc36) that do a range of operations (like read from GCP, write to GCP, data manipulation, etc), but I have been stuck on trying to send an email at the bottom of an R script using the gmailr package for a while now.

I created an issue for @jennybc over at https://github.com/r-lib/gmailr/issues/174 last week, but I thought it may be worth a quick question as to whether gmailr and googleCloudRunner are compatible with each other. When you hear 403 error does that sound like something you'd expect if someone tried to send an email remotely using gmailr from an R script using googleCloudRunner?

jennybc commented 1 year ago

I think you're a bit off-base with the subject. I don't think the the compatibility of gmailr and googleCloudRunner is really the point. They have separate auth mechanisms and I think the default behaviour of googleCloudRunner is achieving what you want and the default for gmailr is not.

sommerhd-royals commented 1 year ago

Thanks @jennybc for your feedback. Google Support directed me to reach out to R package authors that might know more, so I was following their advice. You're probably correct, I just thought it was worth a quick question as this may be a complex issue of package interaction.

MarkEdmondson1234 commented 1 year ago

The gmailr authentication needs to be carried out within its own step, so your upload of any auth files made available in a Docker container or similar. But see also https://code.markedmondson.me/googleCloudRunner/reference/cr_buildstep_mailgun.html for a Mailgun implementation

I also used the great blastula package ( https://pkgs.rstudio.com/blastula ) which had an easy way to upload email authentication, there is an example using it with googleCloudRunner at the bottom of this blog post:

https://code.markedmondson.me/sending-ga4-events-pubsub/