tlverse/origami

Forgotten future.seed = TRUE in future_lapply()

Closed this issue · 1 comments

The new future 1.16.0 has an optional check for cases when parallel RNGs are forgotten. This check is by default disabled, but can be set to signal a warning or an error. When enabling errors, it will reveal this error when building your vignette:

$ export R_FUTURE_RNG_ONMISUSE=error
$ R CMD build origami 
* checking for file 'origami/DESCRIPTION' ... OK
* preparing 'origami':
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... ERROR
--- re-building ‘generalizedCV.Rmd’ using rmarkdown
Quitting from lines 249-254 (generalizedCV.Rmd) 
Error: processing vignette 'generalizedCV.Rmd' failed with diagnostics:
UNRELIABLE VALUE: Future ('future_lapply-1') unexpectedly generated random numbers
without specifying argument '[future.]seed'. There is a risk that those random numbers are
not statistically sound and the overall results might be invalid. To fix this, specify argument
argument '[future.]seed', e.g. 'seed=TRUE'. This ensures that proper, parallel-safe random
 numbers are produced via the L'Ecuyer-CMRG method. To disable this check, set option
 'future.rng.onMisuse' to "ignore".
--- failed re-building ‘generalizedCV.Rmd’

SUMMARY: processing the following file failed:
  ‘generalizedCV.Rmd’

Error: Vignette re-building failed.
Execution halted

The fix is to make sure to pass future_lapply(..., future.seed = TRUE).

This is nothing urgent, but you might wanna fix this already now, since CV functions that rely on random numbers should really use a parallel-safe RNG. There will be a several more releases of the future package before this becomes an error by default, if ever. The plan is to enable warnings in a not too far future. For a background, see HenrikBengtsson/future#353

Thanks for reporting this @HenrikBengtsson! We've fixed it in 464a25c.