Skip to content

Commit

Permalink
Merge pull request #537 from njtierney/remove-future-multiprocess-394
Browse files Browse the repository at this point in the history
removes mention and use of plan(multiprocess)
  • Loading branch information
njtierney authored Sep 8, 2022
2 parents c1b0452 + 995df6b commit a9b5515
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 49 deletions.
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

* Issue where `future` and `parallely` packages error when a CPU with only one core is provided (#513, #516).

# greta 0.4.2.9000

## Fixes

* Removes any use of `multiprocess` as it is deprecated in the `future` package (#394)

# greta 0.4.2.9000

## Fixes

* Removes any use of `multiprocess` as it is deprecated in the `future` package (#394)

# greta 0.4.2

## Fixes
Expand Down
6 changes: 2 additions & 4 deletions R/checkers.R
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ check_future_plan <- function() {
plan_is <- list(
parallel = !inherits(plan_info, "sequential"),
cluster = inherits(plan_info, "cluster"),
multiprocess = inherits(plan_info, "multiprocess"),
multisession = inherits(plan_info, "multisession"),
local = TRUE
)
Expand All @@ -559,10 +558,9 @@ check_future_plan <- function() {
} else {

# if multi*, check it's multisession
if (plan_is$multiprocess && !plan_is$multisession) {
if (!plan_is$multisession) {
msg <- cli::format_error(
"parallel mcmc samplers cannot be run with \\
{.code plan(multiprocess)} or {.code plan(multicore)}"
"parallel mcmc samplers cannot be run with {.code plan(multicore)}"
)
stop(
msg,
Expand Down
45 changes: 43 additions & 2 deletions tests/testthat/_snaps/future.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
# check_future_plan() works when only one core available

$parallel
[1] TRUE

$cluster
[1] TRUE

$multisession
[1] TRUE

$local
[1] TRUE


# check_future_plan() works

$parallel
[1] TRUE

$cluster
[1] TRUE

$multisession
[1] TRUE

$local
[1] TRUE


# mcmc errors for invalid parallel plans

parallel mcmc samplers cannot be run with `plan(multiprocess)` or `plan(multicore)`
$parallel
[1] TRUE

$cluster
[1] TRUE

$multisession
[1] TRUE

$local
[1] TRUE


---

parallel mcmc samplers cannot be run with `plan(multiprocess)` or `plan(multicore)`
parallel mcmc samplers cannot be run with `plan(multicore)`

---

Expand Down
6 changes: 1 addition & 5 deletions tests/testthat/_snaps/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,7 @@

# mcmc errors for invalid parallel plans

parallel mcmc samplers cannot be run with `plan(multiprocess)` or `plan(multicore)`

---

parallel mcmc samplers cannot be run with `plan(multiprocess)` or `plan(multicore)`
parallel mcmc samplers cannot be run with `plan(multicore)`

---

Expand Down
15 changes: 0 additions & 15 deletions tests/testthat/_snaps/install_greta_deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,3 @@
Then, restart R, and load greta with:
`library(greta)`

# reinstall_greta_deps errors appropriately

Stopping as installation of greta dependencies took longer than 0.001 minutes
You can increase the timeout time by increasing the `timeout` argument.
For example, to wait 5 minutes:
`install_greta_deps(timeout = 5)`
Alternatively, you can perform the entire installation with:
`reticulate::install_miniconda()`
Then:
`reticulate::conda_create(envname = 'greta-env', python_version = '3.7')`
Then:
`reticulate::conda_install(envname = 'greta-env', packages = c('numpy==1.16.4', 'tensorflow-probability==0.7.0', 'tensorflow==1.14.0'))`
Then, restart R, and load greta with:
`library(greta)`

8 changes: 0 additions & 8 deletions tests/testthat/_snaps/tensorflow-rpkg-stability.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

integer(0)

---

Tensor("Reshape:0", shape=(1, 1, 1, 1, 1), dtype=int32)

# shape returns right thing

TensorShape([])
Expand Down Expand Up @@ -103,10 +99,6 @@

[1] NA 3

---

Tensor("Const_8:0", shape=(2), dtype=int32)

---

NULL
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-tensorflow-rpkg-stability.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ test_that("Tensor behaves as we expect",{
x <- tensorflow::as_tensor(42, "int32")
expect_snapshot_output(length(x))
expect_snapshot_output(dim(x))
expect_snapshot_output(
tf$reshape(x, tensorflow::as_tensor(shape(-1, 1, 1L, 1, 1L)))
)
})

test_that("shape returns right thing", {
Expand Down Expand Up @@ -80,7 +77,6 @@ test_that("TensorShape conversions remain stable", {
x <- shape(NA, 3)
expect_snapshot_output(as.list(x))
expect_snapshot_output(as.integer(x))
expect_snapshot_output(tensorflow::as_tensor(x))
expect_snapshot_output(x[[1]])
expect_snapshot_output(x[[2]])
})
Expand Down
14 changes: 9 additions & 5 deletions tests/testthat/test_future.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ test_that("check_future_plan() works when only one core available", {
future::plan(future::multisession)

# one chain
expect_error(check_future_plan(), NA)
expect_snapshot_output(
check_future_plan()
)

})

Expand All @@ -18,7 +20,9 @@ test_that("check_future_plan() works", {
future::plan(future::multisession)

# one chain
expect_error(check_future_plan(), NA)
expect_snapshot_output(
check_future_plan()
)

})

Expand All @@ -30,9 +34,9 @@ test_that("mcmc errors for invalid parallel plans", {
# temporarily silence future's warning about multicore support
withr::local_envvar("R_FUTURE_SUPPORTSMULTICORE_UNSTABLE" = "quiet")

# handle handle forks, so only accept multisession, or multi session clusters
suppressWarnings(future::plan(future::multiprocess))
expect_snapshot_error(
# handle forks, so only accept multisession, or multi session clusters
future::plan(future::multisession)
expect_snapshot_output(
check_future_plan()
)

Expand Down
6 changes: 0 additions & 6 deletions tests/testthat/test_inference.R
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,6 @@ test_that("mcmc errors for invalid parallel plans", {
# reset warning setting
withr::defer(future::plan(op))

# handle handle forks, so only accept multisession, or multi session clusters
suppressWarnings(future::plan(future::multiprocess))
expect_snapshot_error(
mcmc(m, verbose = FALSE)
)

future::plan(future::multicore)
expect_snapshot_error(
mcmc(m, verbose = FALSE)
Expand Down

0 comments on commit a9b5515

Please sign in to comment.