Closed HenrikBengtsson closed 1 year ago
Forgot to say, in the same vein, you can undo your doFuture::registerDoFuture()
call using:
oldDoPar <- registerDoFuture()
on.exit(with(oldDoPar, foreach::setDoPar(fun=fun, data=data, info=info)), add = TRUE)
This is explained in Section 'For package developers' of https://dofuture.futureverse.org/reference/registerDoFuture.html.
Like #396, your comment sounds like it refers to something inside a function (the mentioned file only belongs to the tests). I don't think I can use on.exit()
in a test file (outside of a function), can I?
Oh my, I missed it was a test script. So, yeah, ignore my comment/request. I came to this while troubleshooting a reverse dependency issue with doFuture.
I see that you use:
https://github.com/stan-dev/projpred/blob/d6d9744b7ee84b9c14cffb846fc057195588f026/tests/testthat/test_parallel.R#L84
in an attempt to "undo" the future plan you have set earlier in:
https://github.com/stan-dev/projpred/blob/d6d9744b7ee84b9c14cffb846fc057195588f026/tests/testthat/test_parallel.R#L13-L21
Note that the user might have had another plan than the
sequential
set before, which means calling your function may change what the user have intended. A better solution is outlined in Section 'For package developers' of https://future.futureverse.org/reference/plan.html;Could you please update your code to do that instead?