rstudio / promises

A promise library for R
https://rstudio.github.io/promises
Other
201 stars 19 forks source link

future_map inside the body of future_promise can only run sequentially #102

Closed datatenk closed 10 months ago

datatenk commented 11 months ago
library(future)
plan(list(tweak(multisession, workers=2),tweak(multisession, workers=4) ) )

f1<-function(){
    my_input<-some_list
    mu_function<-some_function
    my_result<-furrr::future_map(my_input,my_function)
}

f2<-function(){
    promises::future_promises({
        f1()
    })
}

The code above, f2 function is intended to be a Plumber endpoint function that uses future_promise to launch new tasks (execution of f1 function, which is a slow code). The f1 function uses furrr::future_map to iterate. In the future plan, I set the outer and inner workers to 2 and 4 respectively, which is intended to allocate 2 workers on the Plumber R session for launching function f1, and after these f1-running workers have launched, 4 workers within each f1-launching worker to execute my_function. I have only been able to run my_function (through furrr::future_map) sequentially, rather than the intended 4 workers topology.