Skip to contents

Set pipeline inputs, execute, and read pipeline outputs

Usage

pipeline(
  pipeline_name,
  settings_file = "settings.yaml",
  paths = pipeline_root(),
  temporary = FALSE
)

pipeline_from_path(path, settings_file = "settings.yaml")

Arguments

pipeline_name

the name of the pipeline, usually title field in the 'DESCRIPTION' file, or the pipeline folder name (if description file is missing)

settings_file

the name of the settings file, usually stores user inputs

paths

the paths to search for the pipeline, usually the parent directory of the pipeline; default is pipeline_root, which only search for pipelines that are installed or in current working directory.

temporary

see pipeline_root

path

the pipeline folder

Value

A PipelineTools instance

Examples


if(!is_on_cran()) {

library(raveio)

# ------------ Set up a bare minimal example pipeline ---------------
root_path <- tempdir()
pipeline_root_folder <- file.path(root_path, "modules")

# create pipeline folder
pipeline_path <- pipeline_create_template(
  root_path = pipeline_root_folder, pipeline_name = "raveio_demo",
  overwrite = TRUE, activate = FALSE, template_type = "rmd-bare")

save_yaml(list(
  n = 100, pch = 16, col = "steelblue"
), file = file.path(pipeline_path, "settings.yaml"))

pipeline_build(pipeline_path)

options("raveio.pipeline.project_root" = root_path)

# Compile the pipeline document
rmarkdown::render(input = file.path(pipeline_path, "main.Rmd"),
                  output_dir = pipeline_path,
                  knit_root_dir = pipeline_path,
                  intermediates_dir = pipeline_path, quiet = TRUE)

# Reset options
options("raveio.pipeline.project_root" = NULL)

utils::browseURL(file.path(pipeline_path, "main.html"))

# --------------------- Example starts ------------------------

pipeline <- pipeline(
  pipeline_name = "raveio_demo",
  paths = pipeline_root_folder,
  temporary = TRUE
)

pipeline$run("plot_data")

# Run again and you will see some targets are skipped
pipeline$set_settings(pch = 2)
pipeline$run("plot_data")

head(pipeline$read("input_data"))

# or use
pipeline[c("n", "pch", "col")]
pipeline[-c("input_data")]

pipeline$target_table

pipeline$result_table

pipeline$progress("details")

# --------------------- Clean up ------------------------
unlink(pipeline_path, recursive = TRUE)

}
#> NOT_CRAN is TRUE/true (not on CRAN)
#> 
#> Adding target input_data [R]
#> 
#> Adding target plot_data [R]
#> ▶ dispatched target settings_path
#> ● completed target settings_path [0 seconds, 36 bytes]
#> ▶ dispatched target settings
#> ● completed target settings [0 seconds, 112 bytes]
#> ▶ dispatched target n
#> ● completed target n [0 seconds, 51 bytes]
#> ▶ dispatched target pch
#> ● completed target pch [0 seconds, 51 bytes]
#> ▶ dispatched target col
#> ● completed target col [0 seconds, 62 bytes]
#> ▶ dispatched target input_data
#> ● completed target input_data [0 seconds, 1.276 kilobytes]
#> ▶ dispatched target plot_data

#> ● completed target plot_data [0.001 seconds, 96 bytes]
#> ▶ ended pipeline [0.475 seconds]
#> ▶ dispatched target settings_path
#> ● completed target settings_path [0 seconds, 35 bytes]
#> ▶ dispatched target settings
#> ● completed target settings [0 seconds, 111 bytes]
#> ▶ dispatched target n
#> ● completed target n [0 seconds, 51 bytes]
#> ▶ dispatched target pch
#> ● completed target pch [0 seconds, 50 bytes]
#> ▶ dispatched target col
#> ● completed target col [0.001 seconds, 62 bytes]
#> ✔ skipping targets (1 so far)...
#> ▶ dispatched target plot_data

#> ● completed target plot_data [0 seconds, 96 bytes]
#> ▶ ended pipeline [0.344 seconds]