Skip to content

Commit 4271f31

Browse files
committed
Remove dependency on rstudioapi package
1 parent 97d2c80 commit 4271f31

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ Imports:
3030
nanonext (>= 1.6.2)
3131
Suggests:
3232
cli,
33-
litedown,
34-
rstudioapi
33+
litedown
3534
Enhances:
3635
parallel,
3736
promises

R/launchers.R

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
#'
471471
workbench_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+
}

R/mirai-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
n_zero = "the number of daemons must be zero or greater",
8484
not_found = "compute profile `%s` not found",
8585
numeric_n = "`n` must be numeric, did you mean to provide `url`?",
86-
rstudio_api = "workbench launcher requires the `rstudioapi` package",
86+
rstudio_api = "workbench launcher requires a Posit Workbench environment",
8787
sync_daemons = "mirai: initial sync with daemon(s) [%d secs elapsed]",
8888
sync_dispatcher = "mirai: initial sync with dispatcher [%d secs elapsed]",
8989
within_map = "cannot create local daemons from within mirai map"

0 commit comments

Comments
 (0)