configure_task: Initialize a configuration file for a future task

Description Usage Arguments Value Examples

View source: R/configure_task.R

Description

Initialize a configuration file for a future task

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
configure_task(
  dir_path,
  fun_path,
  fun_name,
  conf_descr = NULL,
  fun_args = NULL,
  priority = 0L,
  compress = TRUE,
  call. = TRUE
)

Arguments

dir_path

character. Tasks location (parent directory).

fun_path

character. Path to the script of the function.

fun_name

character. Name of the function in fun_path script.

conf_descr

named list (NULL). Optional description fields.

fun_args

named list (NULL). Args of the function, must all be named.

priority

numeric (0L). Number used to define which task should be launched first using launcher

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 for function result

call.

logical (TRUE) logical, indicating if the call should become part of the error message (in log file)

Value

a list containing the conf fields. Attribute 'path' of the result contains the path to the conf directory. The arg field contains either the location of the argument (in "dir_path/inputs/arg_name.RDS") or the argument itself if it is of length 1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# create temporary directory
dir <- paste0(tempdir(), "/conf", round(runif(n = 1, max = 10000)))
dir.create(dir, recursive = TRUE)

# create and save conf
conf <- configure_task(dir_path = dir,
                       conf_descr = list(title = "my_title",
                                         description = "my_descr"),
                       fun_path = dir, # as an example
                       fun_name = "my_fun_name",
                       fun_args = list(x = 1,
                                       y = 0:4,
                                       z = iris),
                       priority = 1)

# catch results
list.files(conf$dir)
read_conf <- yaml::read_yaml(paste0(conf$dir, "conf.yml"))
y <- readRDS(paste0(conf$dir, "inputs/y.RDS"))
z <- readRDS(paste0(conf$dir, "inputs/z.RDS"))

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