module_tasks_overview: Module to visualize all the created tasks.

Description Usage Arguments Value See Also Examples

Description

Module to visualize all the created tasks.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
tasks_overview_server(
  input,
  output,
  session,
  dir_path,
  allowed_run_info_cols = c("date_creation", "date_start", "date_end", "priority",
    "status"),
  allow_descr = TRUE,
  allowed_function_cols = c("path", "name"),
  allow_args = TRUE,
  allowed_status = c("waiting", "running", "finished", "error"),
  allow_log_btn = TRUE,
  allow_rm_task = TRUE,
  update_mode = c("reactive", "button"),
  intervalMillis = 1000,
  table_fun = function(x) x,
  return_value = c("selected_task", "tasks_table"),
  ...
)

tasks_overview_UI(
  id,
  labels = list(btn = "Display/update the tasks", empty_global =
    "Empty table of global features.", empty_individual =
    "Empty table of individual features.", error_dir_access =
    "Cannot access given directory.", logs = "Show logs", remove_task =
    "Remove this task ?")
)

Arguments

input

shiny input

output

shiny input

session

shiny input

dir_path

character. Where to find the tasks directorys.

allowed_run_info_cols

character (c("date_creation", "date_start", "date_end", "priority", "status")). Run info elements to be kept.

allow_descr

boolean or character (TRUE). Either a boolean specifying whether or not to keep descr elements, or column names.

allowed_function_cols

character (c("names", "path")). Function elements to be kept.

allow_args

boolean or character (TRUE). Either a boolean specifying whether or not to keep args elements, or column names.

allowed_status

character (c("waiting", "running", "finished", "error")). Vector of allowed status.

allow_log_btn

boolean (TRUE). Whether or not to display a button to show log in modal.

allow_rm_task

boolean (TRUE). Whether or not to display a button to show log in modal.

update_mode

character : "reactive" (default) use shiny::reactivePoll to see if tasks info have changed. "button" add and use a shiny::actionButton to update task info table.

intervalMillis

integer. In case of "reactive" update_mode, time betweens calls

table_fun

function (function(x) x). Function to be applied on the summary table, making it easy to customize it. First arg must be the summmary table.

return_value

character : "selected_task" (default) return the selected task using tasks_overview_UI, else "tasks_table"can be used to get all tasks information and define a custom UI.

...

. Additional args to be given to the table_fun function.

id

character. shiny id to allow multiple instanciation.

labels

list UI labels

Value

if return_value = "selected_task", the status of the selected line (one run) of the summary table and the path to the directory in which its output is stored. if return_value = "tasks_table", all tasks information table

See Also

configure_task_server

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
if(interactive()){

require(shiny)

# create temporary directory for conf
dir_conf <- paste0(tempdir(), "/conf", round(runif(n = 1, max = 10000)))
dir.create(dir_conf, recursive = TRUE)

# ex fun
fun_path = system.file("ex_fun/sb_fun_ex.R", package = "shinybatch")
fun_name = "sb_fun_ex"

# create 2 confs
conf_1 <- configure_task(dir_path = dir_conf,
                         conf_descr = list(title = "my_title_1",
                                           description = "my_descr_1"),
                         fun_path = fun_path,
                         fun_name = fun_name,,
                         fun_args = list(x = 1,
                                         y = 0:4,
                                         z = iris),
                         priority = 1)
conf_2 <- configure_task(dir_path = dir_conf,
                         conf_descr = list(title = "my_title_2",
                                           description = "my_descr_2"),
                         fun_path = fun_path,
                         fun_name = fun_name,
                         fun_args = list(x = 1,
                                         y = 0:4,
                                         z = iris),
                         priority = 2)

run_task(paste0(conf_2$dir, "conf.yml"))

# with package ui
ui <- shiny::fluidPage(
  tasks_overview_UI("my_id_1"),
  hr(),
  verbatimTextOutput("info")
)

server <- function(input, output, session) {
  selected_task <- callModule(tasks_overview_server, "my_id_1",
             dir_path = dir_conf,
             allowed_status = c("waiting", "running", "finished", "error"),
             allowed_run_info_cols = NULL,
             allowed_function_cols = "",
             allow_descr = TRUE,
             allow_args = TRUE,
             table_fun = function(x, y) x[, new_col := y],
             y = "created using arg. 'table_fun'")

  output$info <- renderPrint({
    selected_task()
  })
}
shiny::shinyApp(ui = ui, server = server)

# using custom ui
ui <- shiny::fluidPage(
  verbatimTextOutput("info")
  # and so define what you want !
)

server <- function(input, output, session) {
  all_tasks_info <- callModule(tasks_overview_server, "my_id_1",
             dir_path = dir_conf,
             return_value = "tasks_table"
  )

  output$info <- renderPrint({
    all_tasks_info()
  })
}
shiny::shinyApp(ui = ui, server = server)

}

shinybatch documentation built on June 30, 2021, 9:06 a.m.