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

Using Scheduler to Deploy Multiple Cloud Builds in Parallel #170

Closed MichaelEmmert closed 2 years ago

MichaelEmmert commented 2 years ago

Hello-

This package is awesome, thank you for putting in so much time and effort to make it easy to utilize! I am currently using cr_deploy_r to generate ~25 cloud scheduled jobs that all run in parallel. Is it possible to have one cloud scheduler deploy multiple builds at once for parallel processing?

My initial attempt is below: cr_deploy_r(c("source('./script.R')"), schedule = "0 0 1 ", source = source, run_name = "NAME", timeout = 86400)

script.R for (i in 3:10){ cr_deploy_r(c("print('START')","Sys.sleep(300)","print('FINISHED')")) }

The problem with this is that it waits the entire time for the cr_deploy_r to finish running (in this case 300 seconds) before deploying the next build, which eliminates the parallel processing aspect. Thank you for your time!

MarkEdmondson1234 commented 2 years ago

Thanks!

Yes the deploy functions wait for the builds to run, but if you go a step lower you can use cr_build() and not wait for deployment (the crdeploy* functions are using cr_build_wait() within them. )

MarkEdmondson1234 commented 2 years ago

Reading your use case I would use the new option to use scheduled PubSub triggers for your cloud builds, and run them all off one pubsub event.

MichaelEmmert commented 2 years ago

Great, thank you!