-
Notifications
You must be signed in to change notification settings - Fork 85
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
Working directory set with withr::with_dir() not respected in multisession #363
Comments
(Transferred from the future.apply repos to the future repos, since this question/feedback/feature request applies to all of the future framework) Yeah, that's actually expected. Given that futures can be evaluated anywhere (e.g. on my laptop if I gave you access) - not just on your local machine - it does not really make sense for a future to change the working directory to the working directory on the main R session. That directory might not exist and might not contain the same things. The same limitation goes for files, we cannot really make assumptions about files. A potential solution to this is mentioned in the design roadmap issue 'DESIGN: Future API - Minimal/Core/Essential API and Extended/Optional API':
The gist is to introduce a way for the developer to say that a future requires the local file system to be resolved. Using your example, then you would be able to do something like: opwd <- getwd()
y <- future.apply::future_sapply(1:2, function(x) {
setwd(opwd)
print(getwd())
}, future.resources = local_folder(opwd)) This is far into the future before anything like this is available. Related to this: I think drake has taken several steps toward this model in its support for specifying file dependencies etc. |
To further clarify the above example: If a plan is set with remote workers, then the |
Thanks a lot for the detailed clarification @HenrikBengtsson! It all makes sense now. I wonder if there should be any reference to this in the package documentation or if it is too much of an exotic case. You can close the issue depending on this. |
With current CRAN releases if
future
andfuture.apply
:Created on 2020-03-05 by the reprex package (v0.3.0)
Session info
Source: r-lib/styler#277
The text was updated successfully, but these errors were encountered: