memoise
memoise copied to clipboard
usage with future_map, not finding attached packages
Hi,
thanks for this great package, it has been very useful to me in many instances!
I am not sure if I found a bug or just a limitation of the package. I want to use the package together with future_map
and once a function is memoised, the attached packages are somehow not found by the function anymore.
See the attached minimal reproducible example:
library(future)
library(furrr)
library(xml2)
library(memoise)
library(dplyr)
test_function <- function(url){
return(read_xml(url))
}
future::plan("multisession", workers = 2)
test_data <- tibble(id = 1:10, url ="https://data.europarl.europa.eu/org/5704")
## future_map finds the package, although the external pointer is invalid because of some xml error with future_map
future_map(test_data$url, test_function)
## now lets memoise the function
test_function <- memoise::memoise(test_function)
## future_map does not find the attached xml2 package anymore
future_map(test_data$url, test_function)
## map finds it
map(test_data$url, test_function)
Hope this is the right place for this!
Session Info
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 14393)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.1.4 memoise_2.0.1 xml2_1.3.3 furrr_0.3.1 future_1.28.0
loaded via a namespace (and not attached):
[1] rstudioapi_0.14 parallelly_1.32.1 magrittr_2.0.3 tidyselect_1.2.0 R6_2.5.1 rlang_1.1.2 fastmap_1.1.0
[8] fansi_1.0.4 globals_0.16.1 tools_4.2.2 parallel_4.2.2 utf8_1.2.3 cli_3.6.2 digest_0.6.31
[15] tibble_3.2.1 lifecycle_1.0.3 purrr_1.0.1 vctrs_0.6.5 codetools_0.2-18 glue_1.6.2 cachem_1.0.6
[22] compiler_4.2.2 pillar_1.9.0 generics_0.1.3 listenv_0.8.0 pkgconfig_2.0.3