@@ -109,13 +109,13 @@ launch_remote <- function(
109109 if (is.null(tls )) tls <- envir [[" tls" ]]
110110
111111 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 " )
114114 cluster <- remote [[" name" ]]
115- container <- rstudioapi :: launcherContainer (remote [[" image" ]])
115+ container <- new_container (remote [[" image" ]])
116116 lapply(
117117 seq_len(n ),
118- function (x ) rstudioapi :: launcherSubmitJob (
118+ function (x ) submit_job (
119119 sprintf(" mirai_daemon_%d" , x ),
120120 cluster = cluster ,
121121 command = launch_remote(),
@@ -470,9 +470,8 @@ cluster_config <- function(
470470# ' @export
471471# '
472472workbench_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 ]]
476475 list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
477476}
478477
@@ -559,3 +558,11 @@ find_dot <- function(args) {
559558 any(sel ) || stop(._ [[" dot_required" ]], call. = FALSE )
560559 sel
561560}
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