Skip to content

Commit

Permalink
simplify make_cluster()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Oct 3, 2023
1 parent be650bf commit 72bd53a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/mirai-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ NULL
numeric_n = "'n' must be numeric, did you mean to provide 'url'?",
requires_list = "'.args' must be specified as a list",
requires_local = "SSH tunnelling requires 'url' hostname to be 'localhost' or '127.0.0.1'",
requires_n = "specifying 'url' without 'ssh' requires 'n'",
requires_n = "specifying 'url' without a launch command requires 'n'",
single_url = "only one 'url' should be specified",
sync_dispatch = "initial sync with dispatcher timed out after 5s",
sync_timeout = "sync between host and dispatcher/daemon timed out after 5s",
Expand Down
7 changes: 3 additions & 4 deletions R/parallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,15 @@ make_cluster <- function(n, url = NULL, ..., command = NULL, args = c("", "."),
length(url) == 1L || stop(.messages[["single_url"]])

if (length(command)) {
daemons(url = url, dispatcher = FALSE, resilience = FALSE, cleanup = 0L, ..., .compute = id)
launch_remote(url = url, .compute = id, command = command, args = args, rscript = rscript)
n <- if (is.list(args)) length(args) else 1L

} else {
missing(n) && stop(.messages[["requires_n"]])
daemons(url = url, dispatcher = FALSE, resilience = FALSE, cleanup = 0L, ..., .compute = id)
message(sprintf("%d nodes connecting to '%s' should be launched manually", n, url))
}

daemons(url = url, dispatcher = FALSE, resilience = FALSE, cleanup = 0L, ...,
command = command, args = args, rscript = rscript, .compute = id)

} else {
missing(n) && stop(.messages[["missing_url"]])
is.numeric(n) || stop(.messages[["numeric_n"]])
Expand Down

0 comments on commit 72bd53a

Please sign in to comment.