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

Conflict with furrr? #647

Closed
sammo3182 opened this issue Jun 22, 2023 · 3 comments
Closed

Conflict with furrr? #647

sammo3182 opened this issue Jun 22, 2023 · 3 comments

Comments

@sammo3182
Copy link

Hi Vincent,

I just encountered an error when using both furrr and modelsummary together. I illustrated this in the following example. I guess the problem was caused by some batched function in furrr overwriting the original ones in plain purrr embedded in modelsummary? When inputting each model separately rather than packed as a list into modelsummary, the function works fine.

library(ordinal)
library(modelsummary)

fm1 <- clm(rating ~ temp * contact, data = wine)
fm2 <- update(fm1, ~ . - temp:contact)

modelsummary(list(fm1, fm2))
(1) (2)
1 2 -1.411
(0.545) (0.517)
2 3 1.144
(0.510) (0.438)
3 4 3.377
(0.638) (0.598)
4 5 4.942
(0.751) (0.731)
tempwarm 2.321 2.503
(0.701) (0.529)
contactyes 1.347 1.528
(0.660) (0.477)
tempwarm × contactyes 0.360
(0.924)
:———————- ——–: ——–:
Num.Obs. 72 72
AIC 186.8 185.0
BIC 202.8 198.6
RMSE 2.80 2.80
library(furrr)
#> Loading required package: future

plan(multisession, workers = parallel::detectCores() - 2)
modelsummary(list(fm1, fm2))
#> Error: `modelsummary could not extract the required information from a model of
#>   class "clm". The package tried a sequence of 2 helper functions to
#>   extract estimates:
#>   
#>   parameters::parameters(model)
#>   broom::tidy(model)
#>   
#>   To draw a table, one of these commands must return a `data.frame` with a
#>   column named "term". The `modelsummary` website explains how to
#>   summarize unsupported models or add support for new models yourself:
#>   https://vincentarelbundock.github.io/modelsummary/articles/modelsummary.html
#>   
#>   These errors messages were generated during extraction:
#>   
#>   `parameters::parameters(model)` did not return a valid data.frame.
#> `broom::tidy(model)` did not return a valid data.frame.

Here's my sessionInfo:

sessionInfo()
#> R Under development (unstable) (2023-04-20 r84291 ucrt)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 11 x64 (build 22621)
#> 
#> Matrix products: default
#> 
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.utf8 
#> [2] LC_CTYPE=English_United States.utf8   
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.utf8    
#> 
#> time zone: Asia/Shanghai
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] styler_1.10.1     digest_0.6.31     fastmap_1.1.1     xfun_0.39        
#>  [5] magrittr_2.0.3    glue_1.6.2        R.utils_2.12.2    knitr_1.43       
#>  [9] htmltools_0.5.5   rmarkdown_2.22    lifecycle_1.0.3   cli_3.6.1        
#> [13] R.methodsS3_1.8.2 vctrs_0.6.3       reprex_2.0.2      withr_2.5.0      
#> [17] compiler_4.4.0    R.oo_1.25.0       R.cache_0.16.0    purrr_1.0.1      
#> [21] rstudioapi_0.14   tools_4.4.0       evaluate_0.21     yaml_2.3.7       
#> [25] rlang_1.1.1       fs_1.6.2
@vincentarelbundock
Copy link
Owner

Have you tried disabling future, as described in the Parallel Computation section of the ?modelsummary documentation?

@vincentarelbundock
Copy link
Owner

For what it's worth, I have found parallel problems to be extremely difficult to diagnose, because they depend so much on people's machines, and I can't test that myself. I'd say that if you want to use modelsummary in parallel, it's probably best to use the mc.cores approach if it works on your computer.

vincentarelbundock added a commit that referenced this issue Aug 15, 2023
@vincentarelbundock
Copy link
Owner

Thanks for the report and sorry for the delay. Version 1.4.1.9010 provides a fallback in cases where this error arises, we revert to sequential extraction rather than parallel. This may be a big longer, but at least it won't error anymore.

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