简体   繁体   English

完成后停止 furrr::future_map 打印迭代

[英]Stop furrr::future_map from printing iteration AFTER finishing

I am using future_map to create several plots where I iterate through a list of variables and output/save a png file per variable to a folder.我正在使用 future_map 创建多个图,在其中迭代变量列表并将每个变量的 png 文件输出/保存到文件夹。 So there is no output that needs to be shown in the console or the "plot" pane.所以没有需要在控制台或“绘图”窗格中显示的输出。

The plotting part of the function:函数的绘图部分:

  ggplot(aes(sample = value,
               color = key)) +
    stat_qq(alpha = 0.8, size = 0.5) +
    theme_light() +
    theme(legend.position = "none")  +
    stat_qq_line() +
    facet_wrap(~key,
               ncol = 4) +
    ggtitle(.var) +
    ggsave(filename = here::here(paste0(.path,
                                        .var,
                                        ".png")),
           units = "cm",
           width = 25,
           height = 10)}

How I map the function:我如何映射函数:

plan(multiprocess(workers = 10))
future_map(names_list,
           ~check_dists(df_lips_imputed, .x, "doc/distributions/testing2/"),
           verbose = FALSE)

However, after all files are created, I can see they are in the folder, this is slowly printed (takes a while, ~1k iterations):但是,创建完所有文件后,我可以看到它们在文件夹中,这是慢慢打印的(需要一段时间,~1k 次迭代):

[[1]]

[[2]]

[[3]]

...

Does anyone know how to suppress this output?有谁知道如何抑制这个输出?

Many thanks!非常感谢!

If you install the development version of furrr with如果你安装了开发版的furrr

devtools::install_github("DavisVaughan/furrr")

You can then use future_walk , which is acts like walk does versus map .然后你可以使用future_walk ,这就像walkmap With walk the function acts by side effects and so the return value is simply the input.使用walk函数通过副作用起作用,因此返回值只是输入。

I was having the same issue.我遇到了同样的问题。 I'm not sure if this will change the time that it takes to print out the list elements at the end, but if you save your future_map call as a throwaway variable, it will save the output in that variable instead of printing out and clogging up your console or log file:我不确定这是否会改变最后打印出列表元素所需的时间,但是如果您将future_map调用保存为一次性变量,它会将输出保存在该变量中,而不是打印出来并阻塞启动您的控制台或日志文件:

x <- future_map(names_list,
                ~check_dists(df_lips_imputed, .x, "doc/distributions/testing2/"),
                verbose = FALSE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 嵌套的 furrr::future_map? - Nested furrr::future_map? furrr 中的环境/范围:在 future_map() 中嵌套 get() - Environment/scoping in furrr: nesting get() in future_map() 使用省略号 (...) 将参数传递给 furrr::future_map - Passing arguments to furrr::future_map using ellipsis (…) purrr 的地图有效,但 furrr 的未来地图无效 - purrr's map works, but furrr's future map does not future_map 中的错误:缺少参数“.f”,没有默认值 - Error in future_map: argument ".f" is missing, with no default 在另一个函数中运行 parLapply 和 future_map 不必要地将大对象复制到每个工作人员 - Running parLapply and future_map inside another function unnecessarily copies large objects to each worker 在 Golem Shiny 应用程序中使用 {future} 和 {furrr} 函数时出现错误,它来自什么? - I get an error when using {future} and {furrr} functions within a Golem Shiny App, what does it come from? 当我使用 `dplyr::mutate()` 时,为什么 `furrr::future_map_int()` 比 `purrr::map_int()` 慢? - Why is `furrr::future_map_int()` slower than `purrr::map_int()` when I use `dplyr::mutate()`? R furrr:在运行计算之前验证每个未来进程的 API - R furrr: authenticate an API on each future process before running the computation 停止 lapply 打印到控制台 - Stop lapply from printing to console
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM