Purrr, future, and printing


#1

I’m using the future package to parallelize some code being used with pmap, and the speedup is fantastic. The only thing I’m missing is a way to print an indication of progress, i.e., what slice of the tibble is being worked on. Functions sent to future() don’t seem to be able to return anything to the R console, so I’m at a loss as to how I might indicate progress. Any tips or tricks I can use here?

A reprex that demonstrates what I’m after:

rm(list = ls())

library(magrittr)
library(tidyverse)
library(future)

some.function <- function(a, b) {
  print(sprintf('printing: %s %s', a, b))
}

my.tibble <- tibble(
  one = letters[1:3],
  two = LETTERS[1:3]
)

# standard serial evaluation: prints as expected. Something like this would be helpful.
result <- my.tibble %>%
  mutate(test = pmap(list(one, two), some.function))

# parallel evaluation: no printing?
# Though the result of print() is returned as a side effect 
plan(multiprocess)
result <- my.tibble %>%
  mutate(
    test = pmap(list(one, two), ~future(some.function(..1, ..2))),
    test = map(test, values)
  )

#2

Not a solution, but see Issue #149: