@@ -108,8 +108,10 @@ launch_remote <- function(
108
108
if (is.null(tls )) tls <- envir [[" tls" ]]
109
109
110
110
if (length(remote ) == 2L ) {
111
- submit_job <- .subset2(rstudio(), " .rs.api.launcher.submitJob" )
112
- new_container <- .subset2(rstudio(), " .rs.api.launcher.newContainer" )
111
+ tools <- posit_tools()
112
+ is.environment(tools ) || stop(._ [[" posit_api" ]])
113
+ submit_job <- .subset2(tools , " .rs.api.launcher.submitJob" )
114
+ new_container <- .subset2(tools , " .rs.api.launcher.newContainer" )
113
115
cluster <- remote [[" name" ]]
114
116
container <- new_container(remote [[" image" ]])
115
117
lapply(
@@ -475,12 +477,15 @@ cluster_config <- function(
475
477
cloud_config <- function (platform = " posit" ) {
476
478
switch (
477
479
tolower(platform ),
478
- posit = TRUE ,
480
+ posit = {
481
+ tools <- posit_tools()
482
+ is.environment(tools ) || stop(._ [[" posit_api" ]])
483
+ get_info <- .subset2(tools , " .rs.api.launcher.getInfo" )
484
+ cluster <- get_info()[[" clusters" ]][[1L ]]
485
+ list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
486
+ },
479
487
stop(._ [[" platform_unsupported" ]])
480
488
)
481
- get_info <- .subset2(rstudio(), " .rs.api.launcher.getInfo" )
482
- cluster <- get_info()[[" clusters" ]][[1L ]]
483
- list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
484
489
}
485
490
486
491
# ' URL Constructors
@@ -567,11 +572,11 @@ find_dot <- function(args) {
567
572
sel
568
573
}
569
574
570
- rstudio <- function () {
571
- idx <- match(" tools:rstudio" , search())
572
- is.na( idx ) && stop( ._ [[ " rstudio_api " ]] )
575
+ posit_tools <- function () {
576
+ idx <- match(" tools:rstudio" , search(), nomatch = 0L )
577
+ idx || return ( )
573
578
tools <- as.environment(idx )
574
579
feature_available <- .subset2(tools , " .rs.api.launcher.jobsFeatureAvailable" )
575
- is.function(feature_available ) && feature_available() || stop( ._ [[ " rstudio_api " ]] )
580
+ is.function(feature_available ) && feature_available() || return ( )
576
581
tools
577
582
}
0 commit comments