Skip to content

Commit

Permalink
Merge pull request #152 from shikokuchuo/dev
Browse files Browse the repository at this point in the history
Cleanup Namespace
  • Loading branch information
shikokuchuo authored Sep 13, 2024
2 parents 1a7e45f + c71fdda commit 792379c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 59 deletions.
4 changes: 2 additions & 2 deletions 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: 1.2.0.9013
Version: 1.2.0.9014
Description: Designed for simplicity, a 'mirai' evaluates an R expression
asynchronously in a parallel process, locally or distributed over the
network, with the result automatically available upon completion. Modern
Expand All @@ -26,7 +26,7 @@ Encoding: UTF-8
Depends:
R (>= 3.6)
Imports:
nanonext (>= 1.2.1.9017)
nanonext (>= 1.2.1.9018)
Enhances:
parallel,
promises
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ S3method(promises::as.promise,mirai)
S3method(promises::is.promising,mirai)
S3method(utils::.DollarNames,miraiError)
S3method(with,miraiDaemons)
export(.daemon)
export(.flat)
export(.progress)
export(.progress_cli)
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mirai 1.2.0.9013 (development)
# mirai 1.2.0.9014 (development)

* `daemons(dispatcher = NA)` now provides access to threaded dispatcher (experimental). This implements dispatcher using a thread rather than an external process and is faster and more efficient.
* `mirai_map()` behavioural changes:
Expand All @@ -8,7 +8,7 @@
* Fixes flatmap with `mirai_map()[.flat]` assigning a variable 'typ' to the calling environment.
* `everywhere()` now errors if the specified compute profile is not yet set up, rather than fail silently.
* Internal performance enhancements.
* Requires `nanonext` >= [1.2.1.9017].
* Requires `nanonext` >= [1.2.1.9018].

# mirai 1.2.0

Expand Down
3 changes: 1 addition & 2 deletions R/daemon.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ daemon <- function(url, autoexit = TRUE, cleanup = TRUE, output = FALSE,
#'
#' @return Logical TRUE or FALSE.
#'
#' @keywords internal
#' @export
#' @noRd
#'
.daemon <- function(url) {

Expand Down
8 changes: 4 additions & 4 deletions R/dispatcher.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
#' specified port is not open etc.). Specifying TRUE continues retrying
#' (indefinitely) if not immediately successful, which is more resilient but
#' can mask potential connection issues.
#' @param retry [default FALSE] if TRUE, a task where the daemon crashes or
#' terminates unexpectedly will be automatically re-tried on the next daemon
#' instance to connect. In such a case, the mirai will remain unresolved but
#' @param retry [default FALSE] logical value, whether to automatically retry
#' tasks where the daemon crashes or terminates unexpectedly on the next
#' daemon instance to connect. If TRUE, the mirai will remain unresolved but
#' \code{\link{status}} will show \sQuote{online} as 0 and \sQuote{assigned}
#' > \sQuote{complete}. To cancel a task in such a case, use
#' > \sQuote{complete}. To cancel a task in this case, use
#' \code{saisei(force = TRUE)}. If FALSE, such tasks will be returned as
#' \sQuote{errorValue} 19 (Connection reset).
#' @param token [default FALSE] if TRUE, appends a unique 24-character token
Expand Down
38 changes: 15 additions & 23 deletions R/mirai.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,30 +175,19 @@ mirai <- function(.expr, ..., .args = list(), .timeout = NULL, .compute = "defau
.expr = if (is.symbol(expr) && exists(expr, parent.frame()) && is.language(.expr)) .expr else expr
)
if (length(.args))
data <- c(
if (is.environment(.args)) as.list.environment(.args) else {
length(names(.args)) && all(nzchar(names(.args))) || stop(._[["named_args"]])
.args
},
data
)
data <- c(if (is.environment(.args)) as.list.environment(.args) else
{
length(names(.args)) && all(nzchar(names(.args))) || stop(._[["named_args"]])
.args
},
data)

envir <- ..[[.compute]]

is.null(envir) && {
sock <- ephemeral_daemon(local_url())
aio <- request(
.context(sock), data = data, send_mode = 1L, recv_mode = 1L,
timeout = .timeout, cv = NA
)
`attr<-`(.subset2(aio, "aio"), "sock", sock)
return(aio)
}
is.null(envir) && return(ephemeral_daemon(data = data, timeout = .timeout))

request(
.context(envir[["sock"]]), data = data, send_mode = 1L, recv_mode = 1L,
timeout = .timeout, cv = envir[["cv"]]
)
request(.context(envir[["sock"]]), data = data, send_mode = 1L, recv_mode = 1L,
timeout = .timeout, cv = envir[["cv"]])

}

Expand Down Expand Up @@ -594,10 +583,13 @@ print.miraiInterrupt <- function(x, ...) {

# internals --------------------------------------------------------------------

ephemeral_daemon <- function(url) {
ephemeral_daemon <- function(data, timeout) {
url <- local_url()
sock <- req_socket(url)
system2(command = .command, args = c("-e", shQuote(sprintf("mirai::.daemon(\"%s\")", url))), stdout = FALSE, stderr = FALSE, wait = FALSE)
sock
system2(command = .command, args = c("-e", shQuote(sprintf("mirai:::.daemon(\"%s\")", url))), stdout = FALSE, stderr = FALSE, wait = FALSE)
aio <- request(.context(sock), data = data, send_mode = 1L, recv_mode = 1L, timeout = timeout, cv = NA)
`attr<-`(.subset2(aio, "aio"), "sock", sock)
aio
}

deparse_safe <- function(x) if (length(x))
Expand Down
8 changes: 4 additions & 4 deletions man/dispatcher.Rd

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

21 changes: 0 additions & 21 deletions man/dot-daemon.Rd

This file was deleted.

0 comments on commit 792379c

Please sign in to comment.