launcher: Evaluate and trigger the number of tasks to launch to reach...

Description Usage Arguments Value Examples

View source: R/launcher.R

Description

Evaluate and trigger the number of tasks to launch to reach the maximum allowed

Usage

1
2
3
4
5
6
7
8
launcher(
  dir_path,
  max_runs = 1,
  ignore_status = c("running", "finished", "error"),
  delay_reruns = TRUE,
  compress = TRUE,
  verbose = FALSE
)

Arguments

dir_path

character. Where to find the tasks directory.

max_runs

integer. Maximum number of simultaneous running tasks.

ignore_status

character (c("running", "finished", "error")). Status to be ignored when launching tasks.

delay_reruns

boolean (TRUE). When "running", "finished" or "error" are not in ignore_status, use the date of the last run instead of the date of creation of the task to compute the order of (re)run for these tasks. The priority still applies.

compress

logical or character (TRUE). Either a logical specifying whether or not to use "gzip" compression, or one of "gzip", "bzip2" or "xz" to indicate the type of compression to be used.

verbose

logical See running task message ? Default to FALSE

Value

the number of launched tasks.

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
# 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_1 = "my_title_1",
                           description_1 = "my_descr_1"
                         ),
                         fun_path = fun_path,
                         fun_name = fun_name,
                         fun_args = list(
                           x = 0,
                           y = 0:4,
                           z = iris
                         ),
                         priority = 1)

conf_2 <- configure_task(dir_path = dir_conf,
                         conf_descr = list(
                           title_2 = "my_title_2",
                           description_2 = "my_descr_2"
                         ),
                         fun_path = fun_path,
                         fun_name = fun_name,
                         fun_args = list(
                           x = 1,
                           y = 0:4,
                           z = iris
                         ),
                         priority = 2)

launcher(dir_conf, verbose = TRUE)
# display res of conf_2 in /output dir
Sys.sleep(2) # waiting scheduler computation
readRDS(paste0(conf_2$dir, "output/res.RDS"))

launcher(dir_conf, verbose = TRUE)
# display res of conf_1 in /output dir
Sys.sleep(2) # waiting scheduler computation
readRDS(paste0(conf_1$dir, "output/res.RDS"))

launcher(dir_conf, verbose = TRUE)

# launch again a finished task
launcher(dir_conf, ignore_status = c("running", "error"), verbose = TRUE)

log <- read.delim(paste0(dir_conf, "/log_launcher.txt"), header = FALSE)

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