@@ -95,8 +95,10 @@ launch_remote <- function(n = 1L, remote = remote_config(), ..., tls = NULL, .co
9595 if (is.null(tls )) tls <- envir [[" tls" ]]
9696
9797 if (length(remote ) == 2L ) {
98- submit_job <- .subset2(rstudio(), " .rs.api.launcher.submitJob" )
99- new_container <- .subset2(rstudio(), " .rs.api.launcher.newContainer" )
98+ tools <- posit_tools()
99+ is.environment(tools ) || stop(._ [[" posit_api" ]])
100+ submit_job <- .subset2(tools , " .rs.api.launcher.submitJob" )
101+ new_container <- .subset2(tools , " .rs.api.launcher.newContainer" )
100102 cluster <- remote [[" name" ]]
101103 container <- new_container(remote [[" image" ]])
102104 lapply(
@@ -437,12 +439,15 @@ cluster_config <- function(command = "sbatch", options = "", rscript = "Rscript"
437439cloud_config <- function (platform = " posit" ) {
438440 switch (
439441 tolower(platform ),
440- posit = TRUE ,
442+ posit = {
443+ tools <- posit_tools()
444+ is.environment(tools ) || stop(._ [[" posit_api" ]])
445+ get_info <- .subset2(tools , " .rs.api.launcher.getInfo" )
446+ cluster <- get_info()[[" clusters" ]][[1L ]]
447+ list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
448+ },
441449 stop(._ [[" platform_unsupported" ]])
442450 )
443- get_info <- .subset2(rstudio(), " .rs.api.launcher.getInfo" )
444- cluster <- get_info()[[" clusters" ]][[1L ]]
445- list (name = cluster [[" name" ]], image = cluster [[" defaultImage" ]])
446451}
447452
448453# ' URL Constructors
@@ -530,11 +535,11 @@ find_dot <- function(args) {
530535 sel
531536}
532537
533- rstudio <- function () {
534- idx <- match(" tools:rstudio" , search())
535- is.na( idx ) && stop( ._ [[ " rstudio_api " ]] )
538+ posit_tools <- function () {
539+ idx <- match(" tools:rstudio" , search(), nomatch = 0L )
540+ idx || return ( )
536541 tools <- as.environment(idx )
537542 feature_available <- .subset2(tools , " .rs.api.launcher.jobsFeatureAvailable" )
538- is.function(feature_available ) && feature_available() || stop( ._ [[ " rstudio_api " ]] )
543+ is.function(feature_available ) && feature_available() || return ( )
539544 tools
540545}
0 commit comments