Skip to content

Commit 2fd98e3

Browse files
committed
Remove dependency on rstudioapi package
1 parent 62356ea commit 2fd98e3

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-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: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ launch_remote <- function(
109109
if (is.null(tls)) tls <- envir[["tls"]]
110110

111111
if (length(remote) == 2L) {
112-
requireNamespace("rstudioapi", quietly = TRUE) || stop(._[["rstudio_api"]])
113-
rstudioapi::launcherAvailable()
112+
submit_job <- .subset2(rstudio(), ".rs.api.launcher.submitJob")
113+
new_container <- .subset2(rstudio(), ".rs.api.launcher.newContainer")
114114
cluster <- remote[["name"]]
115-
container <- rstudioapi::launcherContainer(remote[["image"]])
115+
container <- new_container(remote[["image"]])
116116
lapply(
117117
seq_len(n),
118-
function(x) rstudioapi::launcherSubmitJob(
118+
function(x) submit_job(
119119
sprintf("mirai_daemon_%d", x),
120120
cluster = cluster,
121121
command = launch_remote(),
@@ -470,9 +470,8 @@ cluster_config <- function(
470470
#' @export
471471
#'
472472
workbench_config <- function() {
473-
requireNamespace("rstudioapi", quietly = TRUE) || stop(._[["rstudio_api"]])
474-
rstudioapi::launcherAvailable()
475-
cluster <- rstudioapi::launcherGetInfo()[["clusters"]][[1L]]
473+
get_info <- .subset2(rstudio(), ".rs.api.launcher.getInfo")
474+
cluster <- get_info()[["clusters"]][[1L]]
476475
list(name = cluster[["name"]], image = cluster[["defaultImage"]])
477476
}
478477

@@ -559,3 +558,11 @@ find_dot <- function(args) {
559558
any(sel) || stop(._[["dot_required"]], call. = FALSE)
560559
sel
561560
}
561+
562+
rstudio <- function() {
563+
tools <- match("tools:rstudio", search())
564+
is.na(tools) && stop(._[["rstudio_api"]])
565+
exists(".rs.api.launcher.jobsFeatureAvailable", tools) || stop(._[["rstudio_api"]])
566+
tools[[".rs.api.launcher.jobsFeatureAvailable"]]() || stop(._[["rstudio_api"]])
567+
as.environment(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)