Skip to content

Commit

Permalink
CRAN release 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jan 12, 2024
1 parent 8fdb863 commit 1c7a05a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 27 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.11.3.9005
Version: 0.12.0
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.11.3.9005 (development)
# mirai 0.12.0

* More minimal print methods for 'mirai' and 'miraiCluster'.
* Adds `local_url()` helper to construct a random inter-process communications URL for local daemons (thanks @noamross #90).
Expand Down
10 changes: 8 additions & 2 deletions vignettes/promises.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,28 @@ Alternatively, it may be converted into a promise by `as.promise()`, which then
The following example outputs "hello" to the console after one second when the 'mirai' resolves.

```r
library(mirai)
library(promises)

p <- mirai({Sys.sleep(1); "hello"}) %...>% cat()
p
#> <Promise [pending]>
```
It is possible to both access a 'mirai' value at `$data` and to use a promise for enacting a side effect (assigning the value to an environment in the example below).

```r
library(mirai)
library(promises)

env <- new.env()

m <- mirai({Sys.sleep(1); "hello"})
p <- as.promise(m)$then(function(x) env[["response"]] <- x)
p <- as.promise(m)$then(function(x) env$res <- x)

call_mirai(m)$data
#> [1] "hello"
env[["response"]]

# after returning to the top level prompt:
env$res
#> [1] "hello"
```
10 changes: 8 additions & 2 deletions vignettes/promises.Rmd.orig
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ Alternatively, it may be converted into a promise by `as.promise()`, which then

The following example outputs "hello" to the console after one second when the 'mirai' resolves.
```{r promises}
library(mirai)
library(promises)

p <- mirai({Sys.sleep(1); "hello"}) %...>% cat()
p
```
It is possible to both access a 'mirai' value at `$data` and to use a promise for enacting a side effect (assigning the value to an environment in the example below).
```{r promisesalt}
library(mirai)
library(promises)

env <- new.env()

m <- mirai({Sys.sleep(1); "hello"})
p <- as.promise(m)$then(function(x) env[["response"]] <- x)
p <- as.promise(m)$then(function(x) env$res <- x)

call_mirai(m)$data
env[["response"]]

# after returning to the top level prompt:
env$res
```
44 changes: 23 additions & 21 deletions vignettes/torch.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ This allows tensors from the [{torch}](https://cran.r-project.org/package=torch)


```r
library(mirai)
library(torch)

serialization(refhook = list(torch:::torch_serialize, torch::torch_load))
daemons(1)
#> [1] 1
Expand Down Expand Up @@ -69,35 +71,35 @@ The returned model is an object containing many tensor elements.
m$data$parameters$conv1.weight
#> torch_tensor
#> (1,1,.,.) =
#> -0.0679 0.1029 0.1385 0.1610 -0.0206
#> -0.0851 -0.0514 -0.1901 0.0832 0.1121
#> 0.1122 0.0309 -0.1937 -0.1249 0.0343
#> 0.1398 -0.0798 0.0933 0.0672 -0.0778
#> -0.0879 -0.0727 -0.1004 0.1328 0.0231
#> 0.0383 0.1520 0.1109 0.0119 -0.1000
#> 0.0859 -0.1157 0.0960 0.1383 0.0737
#> 0.0155 0.1152 -0.1734 0.1927 -0.0850
#> 0.1287 0.0048 -0.1009 0.1470 0.0258
#> 0.1092 0.0588 0.0504 -0.0591 0.1244
#>
#> (2,1,.,.) =
#> 0.1520 -0.0140 0.0621 0.1891 -0.0192
#> 0.1381 0.1579 0.0415 0.1586 -0.1211
#> -0.0809 -0.0243 -0.1879 -0.1244 -0.1937
#> 0.0408 0.1539 -0.0597 -0.1490 0.1888
#> 0.1035 0.0616 0.0775 0.0979 -0.1342
#> -0.0541 0.0569 0.1552 -0.1217 0.0598
#> 0.1246 -0.0290 -0.0351 0.0297 0.1209
#> 0.0211 0.1039 -0.1791 -0.0348 -0.0183
#> -0.1237 -0.1135 -0.1998 -0.1210 0.1453
#> 0.1361 -0.1181 -0.0830 -0.1544 -0.0032
#>
#> (3,1,.,.) =
#> 0.0944 -0.1438 -0.0957 -0.1855 -0.1500
#> -0.1392 -0.1959 -0.0065 0.1261 -0.1844
#> 0.1375 0.0872 -0.0247 -0.1190 0.1837
#> 0.0579 -0.0641 0.1278 -0.1847 -0.1106
#> -0.0202 -0.1681 0.0986 -0.1300 0.1095
#> -0.1499 0.0196 0.1844 -0.0930 -0.1070
#> 0.0126 -0.0639 -0.0543 -0.1243 0.1572
#> -0.1456 0.1143 0.1234 0.0045 0.0432
#> -0.0010 0.0277 -0.1796 0.1019 -0.1668
#> -0.1633 -0.0722 -0.1908 -0.0810 -0.1464
#>
#> (4,1,.,.) =
#> 0.0105 0.0562 0.1678 0.1800 0.1642
#> 0.1107 -0.0196 -0.0244 -0.1933 -0.1752
#> -0.1280 0.0362 -0.1671 -0.0661 0.1871
#> -0.0716 0.1232 0.0725 -0.0820 0.0994
#> -0.1820 -0.1687 0.1173 0.1916 -0.1074
#> 0.0554 -0.0543 0.1105 0.1958 -0.1307
#> 0.0055 -0.0285 0.0316 -0.0255 -0.1464
#> -0.1972 0.1867 0.1503 -0.0229 -0.1025
#> 0.1923 0.1258 -0.1582 0.1873 0.1510
#> -0.1501 0.0139 -0.0719 -0.1983 -0.0373
#>
#> (5,1,.,.) =
#> 0.1298 0.1826 0.1107 -0.0559 0.1817
#> -0.0986 -0.1050 -0.0045 0.1681 -0.1684
#> ... [the output was truncated (use n=-1 to disable)]
#> [ CPUFloatType{20,1,5,5} ][ requires_grad = TRUE ]
```
Expand Down
2 changes: 2 additions & 0 deletions vignettes/torch.Rmd.orig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ This allows tensors from the [{torch}](https://cran.r-project.org/package=torch)
3. Use `everywhere()` to make the {torch} package available on all dameons (for convenience, optional).

```{r tensors}
library(mirai)
library(torch)

serialization(refhook = list(torch:::torch_serialize, torch::torch_load))
daemons(1)
everywhere(library(torch))
Expand Down

0 comments on commit 1c7a05a

Please sign in to comment.