run_task: Run the task defined in a conf file

Description Usage Arguments Value Examples

View source: R/run_task.R

Description

Run the task defined in a conf file

Usage

1
2
3
4
5
6
7
8
run_task(
  conf_path,
  ignore_status = c("running", "finished", "error"),
  save_rds = TRUE,
  compress = TRUE,
  return = TRUE,
  verbose = FALSE
)

Arguments

conf_path

character. Path to the conf file.

ignore_status

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

save_rds

logical Save output in output/res.RDS ? Default to TRUE

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.

return

logical Get back result in R ? Default to TRUE

verbose

logical See running task message ? Default to FALSE

Value

the result of the task (function applied on prepared args).

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
# 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 and save conf
conf <- configure_task(dir_path = dir_conf,
                       conf_descr = list(
                         title = "my_title",
                         description = "my_descr"
                       ),
                       fun_path = fun_path,
                       fun_name = fun_name,
                       fun_args = list(
                         x = 1,
                         y = 0:4,
                         z = iris
                       ),
                       priority = 1)

conf_init <- yaml::read_yaml(paste0(conf$dir, "conf.yml"))
y <- readRDS(paste0(conf$dir, "inputs/y.RDS"))
z <- readRDS(paste0(conf$dir, "inputs/z.RDS"))

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

# catch results
list.files(conf$dir)
conf_update <- yaml::read_yaml(paste0(conf$dir, "conf.yml"))
output <- readRDS(paste0(conf$dir, "output/res.RDS"))
log <- read.delim(list.files(paste0(conf$dir, "output/"),
                             pattern = "log_run", full.names = TRUE), header = FALSE)

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