Skip to content

Commit 1960c45

Browse files
committed
Refactor a bit
1 parent 9f39a6d commit 1960c45

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

R/launchers.R

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,10 @@ launch_remote <- function(n = 1L, remote = remote_config(), ..., tls = NULL, .co
9797
if (length(remote) == 2L) {
9898
platform <- remote[["platform"]]
9999
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_%s", random(3L)),
112-
cluster = cluster,
113-
command = cmd,
114-
container = container
115-
)
116-
)
117-
return(cmds)
118-
}
119-
stop(._[["platform_unsupported"]])
100+
platform != "posit" && stop(._[["platform_unsupported"]])
101+
tools <- posit_tools()
102+
is.environment(tools) || stop(._[["posit_api"]])
103+
return(posit_workbench_launch(n, args, tools))
120104
}
121105

122106
command <- remote[["command"]]
@@ -551,3 +535,20 @@ posit_tools <- function() {
551535
is.function(feature_available) && feature_available() || return()
552536
tools
553537
}
538+
539+
posit_workbench_launch <- function(n, args, tools) {
540+
submit_job <- .subset2(tools, ".rs.api.launcher.submitJob")
541+
new_container <- .subset2(tools, ".rs.api.launcher.newContainer")
542+
cluster <- args[["name"]]
543+
container <- new_container(args[["image"]])
544+
cmds <- launch_remote(n)
545+
lapply(cmds, function(cmd)
546+
submit_job(
547+
sprintf("mirai_daemon_%s", random(3L)),
548+
cluster = cluster,
549+
command = cmd,
550+
container = container
551+
)
552+
)
553+
cmds
554+
}

0 commit comments

Comments
 (0)