@@ -108,13 +108,13 @@ launch_remote <- function(
108108 if (is.null(tls )) tls <- envir [[" tls" ]]
109109
110110 if (length(remote ) == 2L ) {
111- requireNamespace( " rstudioapi " , quietly = TRUE ) || stop( ._ [[ " rstudio_api " ]] )
112- rstudioapi :: launcherAvailable( )
111+ submit_job <- .subset2(rstudio(), " .rs.api.launcher.submitJob " )
112+ new_container <- .subset2(rstudio(), " .rs.api.launcher.newContainer " )
113113 cluster <- remote [[" name" ]]
114- container <- rstudioapi :: launcherContainer (remote [[" image" ]])
114+ container <- new_container (remote [[" image" ]])
115115 lapply(
116116 seq_len(n ),
117- function (x ) rstudioapi :: launcherSubmitJob (
117+ function (x ) submit_job (
118118 sprintf(" mirai_daemon_%d" , x ),
119119 cluster = cluster ,
120120 command = launch_remote(),
@@ -469,9 +469,8 @@ cluster_config <- function(
469469# ' @export
470470# '
471471workbench_config <- function () {
472- requireNamespace(" rstudioapi" , quietly = TRUE ) || stop(._ [[" rstudio_api" ]])
473- rstudioapi :: launcherAvailable()
474- cluster <- rstudioapi :: launcherGetInfo()[[" clusters" ]][[1L ]]
472+ get_info <- .subset2(rstudio(), " .rs.api.launcher.getInfo" )
473+ cluster <- get_info()[[" clusters" ]][[1L ]]
475474 list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
476475}
477476
@@ -558,3 +557,12 @@ find_dot <- function(args) {
558557 any(sel ) || stop(._ [[" dot_required" ]], call. = FALSE )
559558 sel
560559}
560+
561+ rstudio <- function () {
562+ idx <- match(" tools:rstudio" , search())
563+ is.na(idx ) && stop(._ [[" rstudio_api" ]])
564+ tools <- as.environment(idx )
565+ feature_available <- .subset2(tools , " .rs.api.launcher.jobsFeatureAvailable" )
566+ is.function(feature_available ) && feature_available() || stop(._ [[" rstudio_api" ]])
567+ tools
568+ }
0 commit comments