Open
Description
The following minimal code seems to works flawlessly with handlers("progress") both in linux and windows.
handler_shiny only seems to work in parallel with a windows os.
The linux shiny app only shows half of the progress steps in a sequential order.
Any advice?
library(shiny)
library(progressr)
library(purrr)
library(furrr)
library(tibble)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my_fct <- function(x,
workers = 2
) {
my_steps <- nrow(dplyr::bind_rows(x))
p <- progressor(steps = my_steps * workers)
set.seed(123)
future::plan(multisession, workers = workers)
x |>
furrr::future_walk(\(list) {
list[[1]] |>
purrr::walk(\(item) {
Sys.sleep(.25)
p(message = item)
})
})
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my_list <- list(one = tibble(a = as.character(1:20)),
two = tibble(a = letters[1:20]))
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#future::plan(multisession, workers = 2)
handlers("progress")
system.time(progressr::with_progress(my_list |> my_fct()))
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shinyApp(
ui = fluidPage(plotOutput("plot")),
server = function(input, output) {
output$plot <- renderPlot({
progressr::withProgressShiny(
message = "Calculation in progress",
detail = "Starting ...",
value = 0,
handlers = c(shiny = handler_shiny,
progressr::handlers(default = 'progress')),
{
result <- my_list |>
my_fct()
plot(cars)
}
)
})
}
)
Metadata
Metadata
Assignees
Labels
No labels