-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more minimal print methods; faster promises method
- Loading branch information
1 parent
5d9bd0d
commit 5b18251
Showing
10 changed files
with
99 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2022-2023 Hibiki AI Limited <[email protected]> | ||
# Copyright (C) 2022-2024 Hibiki AI Limited <[email protected]> | ||
# | ||
# This file is part of mirai. | ||
# | ||
|
@@ -454,9 +454,9 @@ serialization <- function(refhook = list()) { | |
|
||
if (register) { | ||
if (is.list(refhook) && length(refhook) == 2L && is.function(refhook[[1L]]) && is.function(refhook[[2L]])) | ||
cat("[ mirai ] serialization functions registered\n", file = stdout()) else | ||
cat("mirai serialization functions registered\n", file = stdout()) else | ||
if (is.null(refhook)) | ||
cat("[ mirai ] serialization functions cancelled\n", file = stdout()) else | ||
cat("mirai serialization functions cancelled\n", file = stdout()) else | ||
stop(._[["refhook_invalid"]]) | ||
register_everywhere(refhook) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2022-2023 Hibiki AI Limited <[email protected]> | ||
# Copyright (C) 2022-2024 Hibiki AI Limited <[email protected]> | ||
# | ||
# This file is part of mirai. | ||
# | ||
|
@@ -119,6 +119,7 @@ registerPromisesMethods <- function(pkgname, pkgpath) { | |
regs <- rbind(ns[[".__NAMESPACE__."]][["S3methods"]], | ||
c("as.promise", "mirai", "as.promise.mirai", NA_character_)) | ||
`[[<-`(ns[[".__NAMESPACE__."]], "S3methods", regs) | ||
`[[<-`(., "later", .getNamespace("later")[["later"]]) | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2022-2023 Hibiki AI Limited <[email protected]> | ||
# Copyright (C) 2022-2024 Hibiki AI Limited <[email protected]> | ||
# | ||
# This file is part of mirai. | ||
# | ||
|
@@ -423,7 +423,7 @@ is_error_value <- is_error_value | |
#' | ||
print.mirai <- function(x, ...) { | ||
|
||
cat("< mirai >\n - $data for evaluated result\n", file = stdout()) | ||
cat("< mirai | $data >\n", file = stdout()) | ||
invisible(x) | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2023 Hibiki AI Limited <[email protected]> | ||
# Copyright (C) 2023-2024 Hibiki AI Limited <[email protected]> | ||
# | ||
# This file is part of mirai. | ||
# | ||
|
@@ -188,7 +188,7 @@ recvOneData.miraiCluster <- function(cl) { | |
print.miraiCluster <- function(x, ...) { | ||
|
||
id <- attr(.subset2(x, 1L), "id") | ||
cat(sprintf("< miraiCluster >\n - cluster ID: %s\n - nodes: %d\n - active: %s\n", id, length(x), as.logical(length(..[[id]]))), file = stdout()) | ||
cat(sprintf("< miraiCluster | ID: %s nodes: %d active: %s >\n", id, length(x), as.logical(length(..[[id]]))), file = stdout()) | ||
invisible(x) | ||
|
||
} | ||
|
@@ -197,7 +197,7 @@ print.miraiCluster <- function(x, ...) { | |
#' | ||
print.miraiNode <- function(x, ...) { | ||
|
||
cat(sprintf("< miraiNode >\n - node: %d\n - cluster ID: %s\n", attr(x, "node"), attr(x, "id")), file = stdout()) | ||
cat(sprintf("< miraiNode | node: %d cluster ID: %s >\n", attr(x, "node"), attr(x, "id")), file = stdout()) | ||
invisible(x) | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2023 Hibiki AI Limited <[email protected]> | ||
# Copyright (C) 2023-2024 Hibiki AI Limited <[email protected]> | ||
# | ||
# This file is part of mirai. | ||
# | ||
|
@@ -53,10 +53,9 @@ | |
as.promise.mirai <- function(x) | ||
promises::promise( | ||
function(resolve, reject) { | ||
later <- .getNamespace("later")[["later"]] | ||
query <- function() | ||
if (unresolved(x)) | ||
later(query, delay = 0.1) else | ||
.[["later"]](query, delay = 0.1) else | ||
if (is_error_value(value <- .subset2(x, "value"))) reject(value) else resolve(value) | ||
query() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
bibentry(bibtype = "Manual", | ||
title = "mirai: Minimalist Async Evaluation Framework for R", | ||
author = person("Charlie", "Gao"), | ||
year = 2023, | ||
year = 2024, | ||
note = sprintf("R package version %s", meta$Version), | ||
url = "https://doi.org/10.5281/zenodo.7912722") |
Oops, something went wrong.