@@ -109,13 +109,13 @@ launch_remote <- function(
109
109
if (is.null(tls )) tls <- envir [[" tls" ]]
110
110
111
111
if (length(remote ) == 2L ) {
112
- requireNamespace( " rstudioapi " , quietly = TRUE ) || stop( ._ [[ " rstudio_api " ]] )
113
- rstudioapi :: launcherAvailable( )
112
+ submit_job <- .subset2(rstudio(), " .rs.api.launcher.submitJob " )
113
+ new_container <- .subset2(rstudio(), " .rs.api.launcher.newContainer " )
114
114
cluster <- remote [[" name" ]]
115
- container <- rstudioapi :: launcherContainer (remote [[" image" ]])
115
+ container <- new_container (remote [[" image" ]])
116
116
lapply(
117
117
seq_len(n ),
118
- function (x ) rstudioapi :: launcherSubmitJob (
118
+ function (x ) submit_job (
119
119
sprintf(" mirai_daemon_%d" , x ),
120
120
cluster = cluster ,
121
121
command = launch_remote(),
@@ -470,9 +470,8 @@ cluster_config <- function(
470
470
# ' @export
471
471
# '
472
472
workbench_config <- function () {
473
- requireNamespace(" rstudioapi" , quietly = TRUE ) || stop(._ [[" rstudio_api" ]])
474
- rstudioapi :: launcherAvailable()
475
- cluster <- rstudioapi :: launcherGetInfo()[[" clusters" ]][[1L ]]
473
+ get_info <- .subset2(rstudio(), " .rs.api.launcher.getInfo" )
474
+ cluster <- get_info()[[" clusters" ]][[1L ]]
476
475
list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
477
476
}
478
477
@@ -559,3 +558,11 @@ find_dot <- function(args) {
559
558
any(sel ) || stop(._ [[" dot_required" ]], call. = FALSE )
560
559
sel
561
560
}
561
+
562
+ rstudio <- function () {
563
+ tools <- match(" tools:rstudio" , search())
564
+ is.na(tools ) && stop(._ [[" rstudio_api" ]])
565
+ exists(" .rs.api.launcher.jobsFeatureAvailable" , tools ) || stop(._ [[" rstudio_api" ]])
566
+ tools [[" .rs.api.launcher.jobsFeatureAvailable" ]]() || stop(._ [[" rstudio_api" ]])
567
+ as.environment(tools )
568
+ }
0 commit comments