Class definition for 'RAVE' pipelines
Class definition for 'RAVE' pipelines
Value
The value of the inputs, or a list if key is missing
The values of the targets
A PipelineResult instance if as_promise
or async is true; otherwise a list of values for input names
An environment of shared variables
See type
A table of the progress
Nothing
ancestor target names (including names)
A new pipeline object based on the path given
A new pipeline object based on the path given
the saved file path
the data if file is found or a default value
A list of key-value pairs
A list of the preferences. If simplify is true and length
if keys is 1, then returns the value of that preference
logical whether the keys exist
A job identification number, see resolve_job for
querying job details
Super class
ravepipeline::RAVESerializable -> PipelineTools
Active bindings
descriptionpipeline description
settings_pathabsolute path to the settings file
extdata_pathabsolute path to the user-defined pipeline data folder
preference_pathdirectory to the pipeline preference folder
target_tabletable of target names and their descriptions
result_tablesummary of the results, including signatures of data and commands
pipeline_paththe absolute path of the pipeline
pipeline_namethe code name of the pipeline
available_reportsavailable reports and their configurations
Methods
Inherited methods
Method new()
construction function
Usage
PipelineTools$new(
pipeline_name,
settings_file = "settings.yaml",
paths = pipeline_root(),
temporary = FALSE
)Arguments
pipeline_namename of the pipeline, usually in the pipeline
'DESCRIPTION'file, or pipeline folder namesettings_filethe file name of the settings file, where the user inputs are stored
pathsthe paths to find the pipeline, usually the parent folder of the pipeline; default is
pipeline_root()temporarywhether not to save
pathsto current pipeline root registry. Set this toTRUEwhen importing pipelines from subject pipeline folders
Method read()
read intermediate variables
Arguments
var_namesthe target names, can be obtained via
x$target_tablemember; default is missing, i.e., to read all the intermediate variablesifnotfoundvariable default value if not found
simplify, ...other parameters passing to
pipeline_read
Method run()
run the pipeline
Arguments
namespipeline variable names to calculate; default is to calculate all the targets
asyncwhether to run asynchronous in another process
as_promisewhether to return a
PipelineResultinstancescheduler, type, envir, callr_function, return_values, debug, ...passed to
pipeline_runifas_promiseis true, otherwise these arguments will be passed topipeline_run_bare
Method eval()
run the pipeline in order; unlike $run(), this method
does not use the targets infrastructure, hence the pipeline
results will not be stored, and the order of names will be
respected.
Usage
PipelineTools$eval(
names,
env = parent.frame(),
shortcut = FALSE,
clean = TRUE,
...
)Arguments
namespipeline variable names to calculate; must be specified
envenvironment to evaluate and store the results
shortcutlogical or characters; default is
FALSE, meaningnamesand all the dependencies (if missing fromenv) will be evaluated; set toTRUEif onlynamesare to be evaluated. Whenshortcutis a character vector, it should be a list of targets (including their ancestors) whose values can be assumed to be up-to-date, and the evaluation of those targets can be skipped.cleanwhether to evaluate without polluting
env...passed to
pipeline_eval
Method shared_env()
run the pipeline shared library in scripts starting with
path R/shared
Usage
PipelineTools$shared_env(callr_function = callr::r)Method python_module()
get 'Python' module embedded in the pipeline
Usage
PipelineTools$python_module(
type = c("info", "module", "shared", "exist"),
must_work = TRUE
)Arguments
typereturn type, choices are
'info'(get basic information such as module path, default),'module'(load module and return it),'shared'(load a shared sub-module from the module, which is shared also in report script), and'exist'(returns true or false on whether the module exists or not)must_workwhether the module needs to be existed or not. If
TRUE, the raise errors when the module does not exist; default isTRUE, ignored whentypeis'exist'.
Method progress()
get progress of the pipeline
Usage
PipelineTools$progress(method = c("summary", "details"))Method attach()
attach pipeline tool to environment (internally used)
Method visualize()
visualize pipeline target dependency graph
Usage
PipelineTools$visualize(
glimpse = FALSE,
aspect_ratio = 2,
node_size = 30,
label_size = 40,
...
)Arguments
glimpsewhether to glimpse the graph network or render the state
aspect_ratiocontrols node spacing
node_size, label_sizesize of nodes and node labels
...passed to
pipeline_visualize
Method fork_to_subject()
fork (copy) the current pipeline to a 'RAVE' subject
Usage
PipelineTools$fork_to_subject(
subject,
label = "NA",
policy = "default",
delete_old = FALSE,
sanitize = TRUE
)Arguments
subjectsubject ID or instance in which pipeline will be saved
labelpipeline label describing the pipeline
policyfork policy defined by module author, see text file 'fork-policy' under the pipeline directory; if missing, then default to avoid copying
main.htmlandsharedfolderdelete_oldwhether to delete old pipelines with the same label default is false
sanitizewhether to sanitize the registry at save. This will remove missing folders and import manually copied pipelines to the registry (only for the pipelines with the same name)
Method with_activated()
run code with pipeline activated, some environment variables
and function behaviors might change under such condition (for example,
targets package functions)
Usage
PipelineTools$with_activated(expr, quoted = FALSE, env = parent.frame())Method clean()
clean all or part of the data store
Usage
PipelineTools$clean(
destroy = c("all", "cloud", "local", "meta", "process", "preferences", "progress",
"objects", "scratch", "workspaces"),
ask = FALSE
)Arguments
destroy, asksee
tar_destroy
Method save_data()
save data to pipeline data folder
Usage
PipelineTools$save_data(
data,
name,
format = c("json", "yaml", "csv", "fst", "rds"),
overwrite = FALSE,
...
)Arguments
dataR object
namethe name of the data to save, must start with letters
formatserialize format, choices are
'json','yaml','csv','fst','rds'; default is'json'. To save arbitrary objects such as functions or environments, use'rds'overwritewhether to overwrite existing files; default is no
...passed to saver functions
Method load_data()
load data from pipeline data folder
Usage
PipelineTools$load_data(
name,
error_if_missing = TRUE,
default_if_missing = NULL,
format = c("auto", "json", "yaml", "csv", "fst", "rds"),
...
)Method set_preferences()
set persistent preferences from the pipeline. The preferences should not affect how pipeline is working, hence usually stores minor variables such as graphic options. Changing preferences will not invalidate pipeline cache.
Arguments
..., .listkey-value pairs of initial preference values. The keys must start with 'global' or the module ID, followed by dot and preference type and names. For example
'global.graphics.continuous_palette'for setting palette colors for continuous heat-map; "global" means the settings should be applied to all 'RAVE' modules. The module-level preference,'power_explorer.export.default_format'sets the default format for power-explorer export dialogue.namepreference name, must contain only letters, digits, underscore, and hyphen, will be coerced to lower case (case-insensitive)
Method get_preferences()
get persistent preferences from the pipeline.
Usage
PipelineTools$get_preferences(
keys,
simplify = TRUE,
ifnotfound = NULL,
validator = NULL,
...
)Arguments
keyscharacters to get the preferences
simplifywhether to simplify the results when length of key is 1; default is true; set to false to always return a list of preferences
ifnotfounddefault value when the key is missing
validatorNULLor function to validate the values; see 'Examples'...passed to
validatorifvalidatoris a function
Examples
library(ravepipeline)
if(interactive() && length(pipeline_list()) > 0) {
pipeline <- pipeline("power_explorer")
# set dummy preference
pipeline$set_preferences("global.example.dummy_preference" = 1:3)
# get preference
pipeline$get_preferences("global.example.dummy_preference")
# get preference with validator to ensure the value length to be 1
pipeline$get_preferences(
"global.example.dummy_preference",
validator = function(value) {
stopifnot(length(value) == 1)
},
ifnotfound = 100
)
pipeline$has_preferences("global.example.dummy_preference")
}
Method generate_report()
generate pipeline
Usage
PipelineTools$generate_report(
name,
subject = NULL,
output_dir = NULL,
output_format = "auto",
clean = FALSE,
...
)Arguments
namereport name, see field
'available_reports'subjectsubject helps determine the
output_dirand working directoriesoutput_dirparent folder where output will be stored
output_formatoutput format
cleanwhether to clean the output; default is false
...passed to
'rmarkdown'render function
Examples
## ------------------------------------------------
## Method `PipelineTools$get_preferences`
## ------------------------------------------------
library(ravepipeline)
if(interactive() && length(pipeline_list()) > 0) {
pipeline <- pipeline("power_explorer")
# set dummy preference
pipeline$set_preferences("global.example.dummy_preference" = 1:3)
# get preference
pipeline$get_preferences("global.example.dummy_preference")
# get preference with validator to ensure the value length to be 1
pipeline$get_preferences(
"global.example.dummy_preference",
validator = function(value) {
stopifnot(length(value) == 1)
},
ifnotfound = 100
)
pipeline$has_preferences("global.example.dummy_preference")
}