Skip to content

Commit

Permalink
validation at remote_config() and ssh_config()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Oct 4, 2023
1 parent 8a12161 commit 17179a2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mirai
Type: Package
Title: Minimalist Async Evaluation Framework for R
Version: 0.10.0.9023
Version: 0.10.0.9024
Description: Lightweight parallel code execution and distributed computing.
Designed for simplicity, a 'mirai' evaluates an R expression asynchronously,
on local or network resources, resolving automatically upon completion.
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mirai 0.10.0.9023 (development)
# mirai 0.10.0.9024 (development)

* Implements an alternative communications backend for R, adding methods for the 'parallel' base package.
+ Fulfils a request by R Core at R Project Sprint 2023, and requires R >= 4.4 (currently R-devel).
Expand Down
13 changes: 7 additions & 6 deletions R/launchers.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,13 @@ launch_remote <- function(url, remote = remote_config(), ..., tls = NULL, .compu
#'
#' @export
#'
remote_config <- function(command = NULL, args = c("", "."), rscript = "Rscript")
remote_config <- function(command = NULL, args = c("", "."), rscript = "Rscript") {

if (is.list(args)) lapply(args, find_dot) else find_dot(args)
list(command = command, args = args, rscript = rscript)

}

#' SSH Remote Launch Configuration
#'
#' \code{ssh_config} generates a remote configuration for launching daemons over
Expand Down Expand Up @@ -272,10 +276,7 @@ ssh_config <- function(remotes, timeout = 5, tunnel = FALSE, command = "ssh", rs
ports <- lapply(premotes, .subset2, "port")

if (tunnel) {
.compute <- dynGet(".compute", ifnotfound = NULL)
url <- if (is.null(.compute) || is.null(..[[.compute]][["urls"]]))
dynGet("url", ifnotfound = stop(.messages[["correct_context"]])) else
..[[.compute]][["urls"]]
url <- dynGet("url", ifnotfound = stop(.messages[["correct_context"]]))
purl <- lapply(url, parse_check_local_url)
plen <- length(purl)
}
Expand All @@ -293,7 +294,7 @@ ssh_config <- function(remotes, timeout = 5, tunnel = FALSE, command = "ssh", rs
)
}

remote_config(command = command, args = args, rscript = rscript)
list(command = command, args = args, rscript = rscript)

}

Expand Down
2 changes: 1 addition & 1 deletion R/mirai-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ NULL
correct_context = "must be called in the correct context e.g. as a function argument",
cluster_inactive = "cluster is no longer active",
daemons_unset = "a numeric value for 'url' requires daemons to be set",
dot_required = "'.' must be an element of (each of) the character vector(s) supplied to 'args'",
dot_required = "'.' must be an element of the character vector(s) supplied to 'args'",
missing_expression = "missing expression, perhaps wrap in {}?",
missing_url = "at least one URL must be supplied for 'url' or 'n' must be at least 1",
n_one = "'n' must be 1 or greater if specified with 'url'",
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ args <- list(m = 2L, n = 4L)
m <- mirai(.expr = `lang obj`, .args = args, .timeout = 2000L)
nanotest(call_mirai(m)$data == 8L || is_error_value(m$data))
Sys.sleep(2.5)
nanotest(daemons(url = value <- mirai:::auto_tokenized_url(), dispatcher = FALSE) == value)
nanotest(daemons(url = value <- mirai:::auto_tokenized_url(), dispatcher = FALSE, remote = remote_config()) == value)
nanotest(grepl("://", launch_remote(status()$daemons), fixed = TRUE))
nanotestz(daemons(0L))
Sys.sleep(1L)
Expand Down

0 comments on commit 17179a2

Please sign in to comment.