Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options change ignored in future_map #36

Closed
Fritzimponis opened this issue Aug 14, 2018 · 1 comment
Closed

options change ignored in future_map #36

Fritzimponis opened this issue Aug 14, 2018 · 1 comment

Comments

@Fritzimponis
Copy link

Fritzimponis commented Aug 14, 2018

I have already asked this question in stack overflow but I didn't get any response so apologies for the cross posting. The question is updated with a reproducible example;

I am trying to use future_map from package furrr within a function I wrote. The function has a dependency on a particular option set in options(). When I change this option to something else it is completely ignored when the function runs in plan(multisession). Is there a way to "inform" every worker on the option change? If I change back to plan(sequential) the function works as expected.

Here is a reproducible example:

# Two functions 
abc <- function(n) {
   n * getOption("tst_value")
}
      
future_abc_mult <- function(n) {
   future_map(n, ~abc(.))
}

# Load packages:
library(furrr)

# Set options:
options(tst_value = 1)

# Try using default plan; sequential  
n = c(1,2,3,4)
future_abc_mult(n)

# Try using multiprocess plan  
plan(multiprocess)
future_abc_mult(n)

Here is my sessionInfo

sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] furrr_0.1.0 future_1.9.0 dplyr_0.7.4 purrr_0.2.5 readr_1.1.1
[6] tidyr_0.7.2 tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.1.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 cellranger_1.1.0 compiler_3.4.2 plyr_1.8.4 bindr_0.1
[6] forcats_0.2.0 tools_3.4.2 digest_0.6.15 lubridate_1.6.0 jsonlite_1.5
[11] nlme_3.1-131 gtable_0.2.0 lattice_0.20-35 pkgconfig_2.0.1 rlang_0.2.1
[16] psych_1.7.8 yaml_2.1.14 parallel_3.4.2 haven_1.1.0 bindrcpp_0.2
[21] xml2_1.1.1 stringr_1.2.0 httr_1.3.1 globals_0.12.1 hms_0.3
[26] grid_3.4.2 glue_1.1.1 listenv_0.7.0 R6_2.2.2 readxl_1.0.0
[31] foreign_0.8-69 modelr_0.1.1 reshape2_1.4.3 magrittr_1.5 codetools_0.2-15
[36] scales_0.5.0 rvest_0.3.2 assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2
[41] stringi_1.1.5 lazyeval_0.2.0 munsell_0.4.3 broom_0.4.2

@DavisVaughan
Copy link
Collaborator

future actually documents this as a still open issue over there. Look there for a few examples of how to do this manually. I agree that it might should be easier, or made more clear, but its not anything that furrr will be able to do so I'm going to close!

futureverse/future#134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants