disable package startup messages when using future.apply::future_lapply with future::multicore
#787
-
|
Is it possible to disable package startup messages in Any thoughts? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
|
Hi, interesting - haven't considered this use case, but totally valid.
Your concern is valid. One clarification though, in R, functions like Future arguments conditions = structure("conditions", exclude = "packageStartupMessage")For library(future.apply)
plan(multicore)
my_fcn <- function(row_sets) {
future_lapply(row_sets, FUN = function(rows) {
# I have to call library() here to get the example to work,
# but normally we don't want to do this
library(mclust)
cat("Stdout still works\n")
message("Messages too")
warning("Warning as well")
mclust::Mclust(iris[rows, 1:4], verbose = FALSE)
}, future.conditions = structure("condition", exclude = "packageStartupMessage"))
}> row_sets <- list(1:50, 51:100, 101:150)
> y <- my_fcn(row_sets)
Stdout still works
Messages too
Stdout still works
Messages too
Stdout still works
Messages too
Warning messages:
1: In ...future.FUN(...future.X_jj, ...) : Warning as well
2: In ...future.FUN(...future.X_jj, ...) : Warning as well
3: In ...future.FUN(...future.X_jj, ...) : Warning as wellPS. The above example was the best I could come up with that emulates what I think you're experiencing. Please try to provide a tiny example when asking for help here or elsewhere - it will save the other person some time and increase your chances for getting a quick reply. I this case I had to go hunt down a package that generated a package startup message. |
Beta Was this translation helpful? Give feedback.
-
Forgot to comment on this one. It does actually happen to all future backend at least ones. For |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @HenrikBengtsson for your detailed reply. Unfortunately, this did not work in my case Here is the output |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @HenrikBengtsson. I always use |
Beta Was this translation helpful? Give feedback.
-
|
I've fixed this in the next release of future; Please retry with: remotes::install_github("HenrikBengtsson/future", ref = "develop") |
Beta Was this translation helpful? Give feedback.
I see what's going on. The
exclude = "packageStartupMessage"takes place after packages infuture.packagesare loaded. This is something I can fix in the next release of the future package.Now, as a workaround, which is actually what I prefer, because it avoids the visual and mental clutter of having to explicitly declare
future.packages, is to "guide" futureverse usingmclust::...in the code, even if just as a no-op, e.g.If you then drop
mclustfromfuture.packages, it will be loaded whenmy_fcn()is called, and thenpackageStartupMessagewill be dropped.