Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed May 15, 2024
2 parents 2d489e7 + 164609a commit 0f68255
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 81 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
extra-packages: |
any::rcmdcheck
any::remotes
needs: check

- name: Check against mirai development version?
if: matrix.config.mirai == 'devel'
run: |
install.packages("remotes")
remotes::install_github("shikokuchuo/nanonext")
remotes::install_github("shikokuchuo/mirai")
shell: Rscript {0}
Expand All @@ -89,4 +90,3 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
error-on: '"note"'

45 changes: 18 additions & 27 deletions .github/workflows/covr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

timeout-minutes: 45

runs-on: ubuntu-22.04
runs-on: ubuntu-latest

name: covr

Expand All @@ -17,48 +17,39 @@ jobs:

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RSPM: https://packagemanager.rstudio.com/cran/__linux__/jammy/latest
R_KEEP_PKG_SOURCE: yes
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
## Test in other locale (optional)
LANGUAGE: ${{ matrix.config.language }}
## R CMD check
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_LENGTH_1_CONDITION_: true
_R_CHECK_LENGTH_1_LOGIC2_: true
_R_CHECK_MATRIX_DATA_: true
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_SUGGESTS_ONLY_: true
_R_CHECK_THINGS_IN_TEMP_DIR_: true
RCMDCHECK_ERROR_ON: note
## Specific to futures
R_FUTURE_RNG_ONMISUSE: error

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: release

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
use-public-rspm: true

- name: Cache R packages
uses: actions/cache@v4
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
extra-packages: |
any::rcmdcheck
any::remotes
any::sessioninfo
any::covr
needs: check

- name: Install dependencies
run: |
install.packages(c("covr", "sessioninfo"))
remotes::install_deps(dependencies = TRUE)
install.packages(".", repos=NULL, type="source")
shell: Rscript {0}
Expand Down
33 changes: 7 additions & 26 deletions .github/workflows/future_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

timeout-minutes: 15

runs-on: ubuntu-22.04
runs-on: ubuntu-latest

name: future.plan=${{ matrix.future.plan }} (${{ matrix.future.label }})

Expand All @@ -21,7 +21,6 @@ jobs:

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RSPM: https://packagemanager.rstudio.com/cran/__linux__/jammy/latest
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
## R CMD check
_R_CHECK_LENGTH_1_CONDITION_: true
Expand All @@ -34,34 +33,16 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: release

- name: Query R package dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
use-public-rspm: true

- name: Cache R packages
uses: actions/cache@v4
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install R package system dependencies (Linux)
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
extra-packages: |
any::rcmdcheck
any::remotes
needs: check

- name: Install R package dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: future.mirai
Version: 0.2.0
Version: 0.2.1
Depends:
future
Imports:
Expand All @@ -11,7 +11,7 @@ Suggests:
future.apply,
listenv
Title: A 'Future' API for Parallel Processing using 'mirai'
Description: Implementation of the 'Future' API <doi:10.32614/RJ-2021-048> on top of the 'mirai' package. This allows you to process futures, as defined by the 'future' package, in parallel out of the box, on your local machine or across remote machines. Contrary to back-ends relying on the 'parallel' package (e.g. 'multisession') and socket connections, 'mirai_cluster' and 'mirai_multisession', provided here, can run more than 125 parallel R processes.
Description: Implementation of the 'Future' API <doi:10.32614/RJ-2021-048> on top of the 'mirai' package <doi:10.5281/zenodo.7912722>. This allows you to process futures, as defined by the 'future' package, in parallel out of the box, on your local machine or across remote machines. Contrary to back-ends relying on the 'parallel' package (e.g. 'multisession') and socket connections, 'mirai_cluster' and 'mirai_multisession', provided here, can run more than 125 parallel R processes.
Authors@R: c(
person("Henrik", "Bengtsson",
role = c("aut", "cre", "cph"),
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Version (development version)

## Bug Fix

* `nbrOfWorkers()` and `nbrOfFreeWorkers()` did not handle mirai
dispatcher errors. Because those are integers, these functions
would return the error integer value instead of giving a
`FutureError`.


# Version 0.2.0

* First public release.
Expand Down
14 changes: 12 additions & 2 deletions R/nbrOfWorkers.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#' @importFrom future nbrOfWorkers FutureWarning FutureError
#' @importFrom mirai status
#' @importFrom mirai is_error_value status
#' @export
nbrOfWorkers.mirai <- function(evaluator) {
res <- status()
workers <- res[["daemons"]]
if (is_error_value(workers)) {
reason <- capture.output(print(workers))
stop(FutureError(sprintf("mirai::status() failed to communicate with dispatcher: %s", reason)))
}

if (is.character(workers)) {
workers <- res[["connections"]]
stopifnot(is.numeric(workers))
Expand All @@ -28,11 +33,16 @@ nbrOfWorkers.mirai <- function(evaluator) {
}

#' @importFrom future nbrOfFreeWorkers FutureError
#' @importFrom mirai status
#' @importFrom mirai is_error_value status
#' @export
nbrOfFreeWorkers.mirai <- function(evaluator, background = FALSE, ...) {
res <- status()
workers <- res[["daemons"]]
if (is_error_value(workers)) {
reason <- capture.output(print(workers))
stop(FutureError(sprintf("mirai::status() failed to communicate with dispatcher: %s", reason)))
}

if (is.character(workers)) {
workers <- res[["connections"]]
stopifnot(is.numeric(workers))
Expand Down
2 changes: 1 addition & 1 deletion R/package.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' future.mirai: A Future API for Parallel Processing using 'callr'
#' future.mirai: A Future API for Parallel Processing using 'mirai'
#'
#' The \pkg{future.mirai} package implements the Future API
#' using the \pkg{mirai} package.
Expand Down
10 changes: 5 additions & 5 deletions R/utils,mirai.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
get_mirai_daemons <- function() {
status <- status()
res <- status[["daemons"]]

if (is_error_value(res)) { # should not assume structure of an error value
reason <- capture.output(print(res))
stop(FutureError(sprintf("mirai::status() failed to communicate with dispatcher: %s", reason)))
}

if (is.character(res)) {
# returns number of daemons if running without dispatcher
return(status[["connections"]])
}

if (is_error_value(res)) { # should not assume structure of an error value
reason <- capture.output(print(res))
stop(FutureError(sprintf("mirai::status() failed to communicate with dispatcher: %s", reason)))
}

as.data.frame(res)

}
17 changes: 8 additions & 9 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# CRAN submission future.mirai 0.2.0
# CRAN submission future.mirai 0.2.1

on 2024-04-12
on 2024-05-14

This is a new package.

I'm using the same terminology, nomenclature and formatting in the package title and description that I use for other closely related "sibling" packages on CRAN, e.g. future.batchtools and future.callr.
This submission attempts to fix a check error that occurs sporadically
and has been reported on the CRAN check servers.

Thanks in advance

Expand All @@ -18,9 +17,9 @@ The package has been verified using `R CMD check --as-cran` on:
| R version | GitHub | mac/win-builder |
| --------- | ------ | --------------- |
| 3.6.x | L | |
| 4.2.x | L W | W |
| 4.3.x | L M W | . W |
| 4.4.x | | W |
| devel | L M W | |
| 4.2.x | L W | |
| 4.3.x | L M W | W |
| 4.4.x | | M1 W |
| devel | L M W | W |

*Legend: OS: L = Linux, M = macOS, M1 = macOS M1, W = Windows*
2 changes: 1 addition & 1 deletion man/future.mirai.Rd

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

21 changes: 16 additions & 5 deletions tests/mirai_cluster,worker-termination.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,22 @@ if (.Platform$OS.type != "windows") {
res <- tryCatch(value(f), error = identity)
print(res)
stopifnot(inherits(res, "FutureError"))

stopifnot(
nbrOfWorkers() == all - 1L,
nbrOfFreeWorkers() == free - 1L
)

## FIXME: nbrOfWorkers()/nbrOfFreeWorkers() can throw a FutureError,
## cf. https://github.com/HenrikBengtsson/future.mirai/issues/7
nworkers <- tryCatch(nbrOfWorkers(), error = identity)
print(nworkers)
if (!inherits(nworkers, "error")) {
message("Number of workers: ", nworkers)
stopifnot(nworkers == all - 1L)
}

nfreeworkers <- tryCatch(nbrOfFreeWorkers(), error = identity)
print(nfreeworkers)
if (!inherits(nfreeworkers, "error")) {
message("Number of free workers: ", nfreeworkers)
stopifnot(nfreeworkers == free - 1L)
}
}

message("*** mirai_multisession() - terminating workers ... DONE")
Expand Down

0 comments on commit 0f68255

Please sign in to comment.