Skip to content

Commit 49458cf

Browse files
committed
cloud_config() -> posit_workbench_config()
1 parent 1960c45 commit 49458cf

File tree

6 files changed

+32
-56
lines changed

6 files changed

+32
-56
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export(.flat)
2626
export(.progress)
2727
export(.stop)
2828
export(call_mirai)
29-
export(cloud_config)
3029
export(cluster_config)
3130
export(collect_mirai)
3231
export(daemon)
@@ -52,6 +51,7 @@ export(nextcode)
5251
export(nextget)
5352
export(nextstream)
5453
export(on_daemon)
54+
export(posit_workbench_config)
5555
export(register_serial)
5656
export(remote_config)
5757
export(require_daemons)

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#### New Features
1212

13-
* Adds `cloud_config()` to launch remote daemons using a cloud / cloud-based managed platform. Currently supports Posit Workbench.
13+
* Adds `posit_workbench_config()` to launch remote daemons using the default Posit Workbench launcher (currently only supports Rstudio Pro sessions).
1414
* Adds `info()` as an alternative to `status()` for retrieving more succinct information statistics, more convenient for programmatic use (thanks @wlandau, #410).
1515
* Adds `with_daemons()` and `local_daemons()` helper functions for using a particular compute profile.
1616
These work with daemons that are already set up unlike the existing `with.miraiDaemons()` method, which creates a new scope and tears it down when finished (#360).

R/launchers.R

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,9 @@ 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-
platform <- remote[["platform"]]
99-
args <- remote[["args"]]
100-
platform != "posit" && stop(._[["platform_unsupported"]])
10198
tools <- posit_tools()
10299
is.environment(tools) || stop(._[["posit_api"]])
103-
return(posit_workbench_launch(n, args, tools))
100+
return(posit_workbench_launch(n, remote, tools))
104101
}
105102

106103
command <- remote[["command"]]
@@ -401,45 +398,33 @@ cluster_config <- function(command = "sbatch", options = "", rscript = "Rscript"
401398
list(command = "/bin/sh", args = args, rscript = rscript, quote = NULL)
402399
}
403400

404-
#' Cloud Remote Launch Configuration
405-
#'
406-
#' Generates a remote configuration for launching daemons via cloud /
407-
#' cloud-based managed platforms.
401+
#' Posit Workbench Launch Configuration
408402
#'
409-
#' @param platform \[default "posit"\] character name of the platform
410-
#' (case-insensitive). Currently the only option is "posit" to use the Posit
411-
#' Workbench launcher.
403+
#' Generates a remote configuration for launching daemons via the default
404+
#' launcher in Posit Workbench. Currently only supports Rstudio Pro sessions.
412405
#'
413406
#' @inherit remote_config return
414407
#'
415408
#' @seealso [ssh_config()], [cluster_config()], and [remote_config()] for other
416409
#' types of remote launch configuration.
417410
#'
418411
#' @examples
419-
#' tryCatch(cloud_config(), error = identity)
412+
#' tryCatch(posit_workbench_config(), error = identity)
420413
#'
421414
#' \dontrun{
422415
#'
423416
#' # Launch 2 daemons using the Posit Workbench default:
424-
#' daemons(n = 2, url = host_url(), remote = cloud_config(platform = "posit"))
417+
#' daemons(n = 2, url = host_url(), remote = posit_workbench_config()
425418
#' }
426419
#'
427420
#' @export
428421
#'
429-
cloud_config <- function(platform = "posit") {
430-
platform <- tolower(platform)
431-
args <- switch(
432-
platform,
433-
posit = {
434-
tools <- posit_tools()
435-
is.environment(tools) || stop(._[["posit_api"]])
436-
get_info <- .subset2(tools, ".rs.api.launcher.getInfo")
437-
cluster <- get_info()[["clusters"]][[1L]]
438-
list(name = cluster[["name"]], image = cluster[["defaultImage"]])
439-
},
440-
stop(._[["platform_unsupported"]])
441-
)
442-
list(platform = platform, args = args)
422+
posit_workbench_config <- function() {
423+
tools <- posit_tools()
424+
is.environment(tools) || stop(._[["posit_api"]])
425+
get_info <- .subset2(tools, ".rs.api.launcher.getInfo")
426+
cluster <- get_info()[["clusters"]][[1L]]
427+
list(name = cluster[["name"]], image = cluster[["defaultImage"]])
443428
}
444429

445430
#' URL Constructors
@@ -536,15 +521,15 @@ posit_tools <- function() {
536521
tools
537522
}
538523

539-
posit_workbench_launch <- function(n, args, tools) {
524+
posit_workbench_launch <- function(n, remote, tools) {
540525
submit_job <- .subset2(tools, ".rs.api.launcher.submitJob")
541526
new_container <- .subset2(tools, ".rs.api.launcher.newContainer")
542-
cluster <- args[["name"]]
543-
container <- new_container(args[["image"]])
527+
cluster <- remote[["name"]]
528+
container <- new_container(remote[["image"]])
544529
cmds <- launch_remote(n)
545530
lapply(cmds, function(cmd)
546531
submit_job(
547-
sprintf("mirai_daemon_%s", random(3L)),
532+
sprintf("mirai_daemon_%s", random(4L)),
548533
cluster = cluster,
549534
command = cmd,
550535
container = container

R/mirai-package.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@
8080
n_zero = "the number of daemons must be zero or greater",
8181
not_found = "compute profile `%s` not found",
8282
numeric_n = "`n` must be numeric, did you mean to provide `url`?",
83-
platform_unsupported = "`platform` is currently not supported",
84-
posit_api = "this launch configuration can only be used from Posit Workbench",
83+
posit_api = "requires Posit Workbench (Rstudio Pro session)",
8584
sync_daemons = "mirai: initial sync with daemon(s) [%d secs elapsed]",
8685
sync_dispatcher = "mirai: initial sync with dispatcher [%d secs elapsed]",
8786
within_map = "cannot create local daemons from within mirai map"

man/cloud_config.Rd renamed to man/posit_workbench_config.Rd

Lines changed: 8 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/tests.R

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,21 @@ for (i in 0:4)
6161
test_null(register_serial("test_klass1", serialize, unserialize))
6262
test_null(register_serial(c("test_klass2", "test_klass3"), list(serialize, serialize), list(unserialize, unserialize)))
6363
test_equal(length(mirai:::.[["serial"]][[3L]]), 3L)
64-
# cloud launcher tests
65-
test_error(cloud_config(platform = ""), "not supported")
64+
# Posit workbench launcher tests
6665
is.null(mirai:::posit_tools()) && {
6766
ns <- new.env(parent = emptyenv())
6867
`[[<-`(ns, ".rs.api.launcher.jobsFeatureAvailable", function() TRUE)
6968
`[[<-`(ns, ".rs.api.launcher.getInfo", function() list(clusters = list(list(name = "Kubernetes", defaultImage = "1.a.b.reg.prov.com/int-r-sess:ubuntu2204-20250609"))))
7069
`[[<-`(ns, ".rs.api.launcher.newContainer", function(image) image)
7170
`[[<-`(ns, ".rs.api.launcher.submitJob", function(...) NULL)
7271
attach(ns, name = "tools:rstudio")
73-
cfg <- cloud_config(platform = "posit")
72+
cfg <- posit_workbench_config()
7473
test_type("list", cfg)
75-
test_zero(daemons(url = local_url(), dispatcher = FALSE))
74+
test_true(daemons(url = local_url(), dispatcher = FALSE))
7675
test_class("miraiLaunchCmd", launch_remote(n = 2L, remote = cfg))
77-
cfg$platform <- "wrong"
78-
test_error(launch_remote(n = 2L, remote = cfg), "not supported")
79-
test_zero(daemons(0))
76+
test_false(daemons(0))
8077
detach()
81-
test_error(cloud_config(platform = "posit"), "can only be used from Posit Workbench")
78+
test_error(posit_workbench_config(), "requires Posit Workbench")
8279
}
8380
# mirai and daemons tests
8481
connection && {

0 commit comments

Comments
 (0)