Skip to content

Commit

Permalink
Add makeClusterSequential() - tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Jul 1, 2024
1 parent 73a8dcf commit 27d14fc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: parallelly
Version: 1.37.1-9010
Version: 1.37.1-9011
Title: Enhancing the 'parallel' Package
Imports:
parallel,
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ S3method(killNode,cluster)
S3method(killNode,default)
S3method(print,RichSOCKcluster)
S3method(print,RichSOCKnode)
S3method(print,sequential_node)
S3method(stopCluster,RichMPIcluster)
S3method(summary,RichSOCKcluster)
S3method(summary,RichSOCKnode)
Expand All @@ -53,9 +52,11 @@ export(makeClusterMPI)
export(makeClusterPSOCK)
export(makeNodePSOCK)
export(supportsMulticore)
if (getRversion() >= "4.4") S3method(print,sequential_cluster)
if (getRversion() >= "4.4") S3method(print,sequential_node)
if (getRversion() >= "4.4") S3method(recvData,sequential_node)
if (getRversion() >= "4.4") S3method(sendData,sequential_node)
if (getRversion() >= "4.4") export(SEQ)
if (getRversion() >= "4.4") export(makeClusterSequential)
if (getRversion() >= "4.4") importFrom(parallel,recvData)
if (getRversion() >= "4.4") importFrom(parallel,sendData)
Expand Down
5 changes: 3 additions & 2 deletions R/makeClusterSequential.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
#' This function is only defined for R (>= 4.4.0).
#'
#' @rawNamespace if (getRversion() >= "4.4") export(makeClusterSequential)
#' @aliases SEQ
makeClusterSequential <- function() {
node <- makeNodeSequential()
cl <- list(node)
class(cl) <- c("sequential_cluster", "cluster")
cl
}

#' @rawNamespace if (getRversion() >= "4.4") S3method(print,sequential_node)
#' @rawNamespace if (getRversion() >= "4.4") S3method(print,sequential_cluster)
print.sequential_cluster <- function(x, ...) {
cat(sprintf("A %s cluster with %d node\n", sQuote(class(x)[1]), length(x)))
}
Expand All @@ -42,7 +43,7 @@ makeNodeSequential <- function() {
node
}

#' @export
#' @rawNamespace if (getRversion() >= "4.4") S3method(print,sequential_node)
print.sequential_node <- function(x, ...) {
cat(sprintf("A %s node\n", sQuote(class(x))))
}
Expand Down
5 changes: 3 additions & 2 deletions R/registerClusterTypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ MPI <- "parallelly::MPI"
#' @rawNamespace export(PSOCK)
PSOCK <- "parallelly::PSOCK"

#' @rawNamespace if (getRversion() >= "4.4") export(SEQ)
SEQ <- "parallelly::SEQ"

registerClusterTypes <- local({
Expand All @@ -25,8 +26,8 @@ registerClusterTypes <- local({
## WORKAROUND: 'R CMD build' somehow creates and calls this function
## twice, resulting in warnings from parallel::registerClusterType().
suppressWarnings({
registerClusterType(MPI, makeClusterMPI, make.default = FALSE)
registerClusterType(PSOCK, makeClusterPSOCK, make.default = FALSE)
registerClusterType(MPI, makeClusterMPI, make.default = FALSE)
registerClusterType(PSOCK, makeClusterPSOCK, make.default = FALSE)
registerClusterType(SEQ, makeClusterSequential, make.default = FALSE)
})
done <<- TRUE
Expand Down
1 change: 1 addition & 0 deletions man/makeClusterSequential.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 27d14fc

Please sign in to comment.