@@ -109,8 +109,10 @@ launch_remote <- function(
109109 if (is.null(tls )) tls <- envir [[" tls" ]]
110110
111111 if (length(remote ) == 2L ) {
112- submit_job <- .subset2(rstudio(), " .rs.api.launcher.submitJob" )
113- new_container <- .subset2(rstudio(), " .rs.api.launcher.newContainer" )
112+ tools <- posit_tools()
113+ is.environment(tools ) || stop(._ [[" posit_api" ]])
114+ submit_job <- .subset2(tools , " .rs.api.launcher.submitJob" )
115+ new_container <- .subset2(tools , " .rs.api.launcher.newContainer" )
114116 cluster <- remote [[" name" ]]
115117 container <- new_container(remote [[" image" ]])
116118 lapply(
@@ -476,12 +478,15 @@ cluster_config <- function(
476478cloud_config <- function (platform = " posit" ) {
477479 switch (
478480 tolower(platform ),
479- posit = TRUE ,
481+ posit = {
482+ tools <- posit_tools()
483+ is.environment(tools ) || stop(._ [[" posit_api" ]])
484+ get_info <- .subset2(tools , " .rs.api.launcher.getInfo" )
485+ cluster <- get_info()[[" clusters" ]][[1L ]]
486+ list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
487+ },
480488 stop(._ [[" platform_unsupported" ]])
481489 )
482- get_info <- .subset2(rstudio(), " .rs.api.launcher.getInfo" )
483- cluster <- get_info()[[" clusters" ]][[1L ]]
484- list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
485490}
486491
487492# ' URL Constructors
@@ -568,11 +573,11 @@ find_dot <- function(args) {
568573 sel
569574}
570575
571- rstudio <- function () {
572- idx <- match(" tools:rstudio" , search())
573- is.na( idx ) && stop( ._ [[ " rstudio_api " ]] )
576+ posit_tools <- function () {
577+ idx <- match(" tools:rstudio" , search(), nomatch = 0L )
578+ idx || return ( )
574579 tools <- as.environment(idx )
575580 feature_available <- .subset2(tools , " .rs.api.launcher.jobsFeatureAvailable" )
576- is.function(feature_available ) && feature_available() || stop( ._ [[ " rstudio_api " ]] )
581+ is.function(feature_available ) && feature_available() || return ( )
577582 tools
578583}
0 commit comments