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

Set memory for cr_deploy_plumber? #126

Closed dcaud closed 2 years ago

dcaud commented 3 years ago

Using the examples, this call is successful:

cr <- cr_deploy_plumber(my_plumber_folder)

However, I tried to change the memory (and other parameters) and got errors:

cr <- cr_deploy_plumber(my_plumber_folder, memory="512Mi")

Which throws an Error about unused arguments. But the documentation says that additional arguments (...) are passed on to cr_buildstep_run.

How do you set those additional arguments with cr_deploy_plumber?

MarkEdmondson1234 commented 3 years ago

Could you show your session info and what error is thrown?

dcaud commented 3 years ago

Thanks for taking a look:

reprex

library(googleCloudRunner)

cr <- cr_deploy_plumber(my_plumber_folder,
                        memory="512Mi")

error

Error in cr_deploy_plumber(my_plumber_folder, memory = "512Mi") : unused argument (memory = "512Mi")

Session Info

R version 4.0.5 (2021-03-31) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Big Sur 10.16

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] googleCloudRunner_0.4.1

loaded via a namespace (and not attached): [1] Rcpp_1.0.7 rstudioapi_0.13 magrittr_2.0.1
[4] googleCloudStorageR_0.6.0 webutils_1.1 R6_2.5.0
[7] rlang_0.4.11 fastmap_1.1.0 httr_1.4.2
[10] tools_4.0.5 jose_1.0 cli_3.0.0
[13] googleAuthR_1.4.0 askpass_1.1 yaml_2.2.1
[16] openssl_1.4.4 assertthat_0.2.1 digest_0.6.27
[19] gargle_1.2.0 lifecycle_1.0.0 zip_2.1.1
[22] plumber_1.1.0 later_1.2.0 promises_1.2.0.1
[25] fs_1.5.0 curl_4.3.2 memoise_2.0.0
[28] glue_1.4.2 cachem_1.0.5 stringi_1.6.2
[31] compiler_4.0.5 swagger_3.33.1 jsonlite_1.7.2

dcaud commented 2 years ago

I believe this error is because the function specification for cr_deploy_plumber does not include the ellipsis necessary to pass other parameters to subsequent functions. I imagine part of a revised function would include:

adding ", ..." to cr_deploy_plumber and to the cr_deploy_run at the end of cr_deploy_plumber

MarkEdmondson1234 commented 2 years ago

This should be fixed now - code now reads

cr_deploy_plumber <- function(api,
                              remote = basename(api),
                              dockerfile = NULL,
                              image_name = remote,
                              tag = "$BUILD_ID",
                              region = cr_region_get(),
                              bucket = cr_bucket_get(),
                              projectId = cr_project_get(),
                              launch_browser = interactive(),
                              timeout = 600L,
                              ...) {
  local <- api
  local_files <- list.files(local)
  if (!"api.R" %in% local_files) {
    stop("Must include api.R in local deployment folder
         with library(plumber) implementation
         for Cloud Run deployments", call. = FALSE)
  }

  # if no dockerfile, attempt to create it
  if (is.null(dockerfile)) {
    if (!"Dockerfile" %in% local_files) {
      myMessage("No Dockerfile detected in ", local, level = 3)
      cr_dockerfile_plumber(local)
    } else {
      myMessage("Using existing Dockerfile found in folder", level = 3)
    }
  }

  cr_deploy_run(
    local = local,
    remote = remote,
    dockerfile = dockerfile,
    image_name = image_name,
    tag = tag,
    region = region,
    bucket = bucket,
    projectId = projectId,
    launch_browser = launch_browser,
    timeout = timeout,
    ... # source of bug
  )
}