Skip to content

Commit 0747416

Browse files
committed
Standardize cloud config structure
1 parent 3b328f9 commit 0747416

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

R/launchers.R

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,28 @@ launch_remote <- function(n = 1L, remote = remote_config(), ..., tls = NULL, .co
9595
if (is.null(tls)) tls <- envir[["tls"]]
9696

9797
if (length(remote) == 2L) {
98-
tools <- posit_tools()
99-
is.environment(tools) || stop(._[["posit_api"]])
100-
submit_job <- .subset2(tools, ".rs.api.launcher.submitJob")
101-
new_container <- .subset2(tools, ".rs.api.launcher.newContainer")
102-
cluster <- remote[["name"]]
103-
container <- new_container(remote[["image"]])
104-
lapply(
105-
seq_len(n),
106-
function(x) submit_job(
107-
sprintf("mirai_daemon_%d", x),
108-
cluster = cluster,
109-
command = launch_remote(),
110-
container = container
98+
platform <- remote[["platform"]]
99+
args <- remote[["args"]]
100+
platform == "posit" && {
101+
tools <- posit_tools()
102+
is.environment(tools) || stop(._[["posit_api"]])
103+
submit_job <- .subset2(tools, ".rs.api.launcher.submitJob")
104+
new_container <- .subset2(tools, ".rs.api.launcher.newContainer")
105+
cluster <- args[["name"]]
106+
container <- new_container(args[["image"]])
107+
cmds <- launch_remote(n)
108+
lapply(
109+
cmds,
110+
function(cmd) submit_job(
111+
sprintf("mirai_daemon_%d", random(4L)),
112+
cluster = cluster,
113+
command = cmd,
114+
container = container
115+
)
111116
)
112-
)
113-
return(invisible())
117+
return(cmds)
118+
}
119+
stop(._[["platform_unsupported"]])
114120
}
115121

116122
command <- remote[["command"]]
@@ -437,8 +443,9 @@ cluster_config <- function(command = "sbatch", options = "", rscript = "Rscript"
437443
#' @export
438444
#'
439445
cloud_config <- function(platform = "posit") {
440-
switch(
441-
tolower(platform),
446+
platform <- tolower(platform)
447+
args <- switch(
448+
platform,
442449
posit = {
443450
tools <- posit_tools()
444451
is.environment(tools) || stop(._[["posit_api"]])
@@ -448,6 +455,7 @@ cloud_config <- function(platform = "posit") {
448455
},
449456
stop(._[["platform_unsupported"]])
450457
)
458+
list(platform = platform, args = args)
451459
}
452460

453461
#' URL Constructors

0 commit comments

Comments
 (0)