intercept_baton: Intercept a baton

View source: R/transfer.R

intercept_batonR Documentation

Intercept a baton

Description

Functionally similar to grab_baton but able to obtain baton before the pass operation is complete.

Usage

intercept_baton(baton, loc = NULL, reset_only = FALSE, env = .GlobalEnv)

Arguments

baton

R object of S3 class, created by create_baton

loc

Location of YAML file that was saved from a baton.

reset_only

boolean value which will attempt only to reset the pass_complete status without loading the baton.

env

R environment to locate and delete duplicate batons during an interception; defaults to .GlobalEnv.

Details

Normally, grab_baton is the preferred method to load a baton. However, there are circumstances where a pass needs to be intercepted mid-pass so that a process can reset and continue. It is recommended to use intercept_baton in limited situations. To avoid loading a baton twice, intercept_baton will attempt to delete any baton in the global environment that shares the same ID; this is a measure to ensure a baton is only being acted on linearly. A warning is also provided to remind users that misuse of this function could lead to unexpected results in the YAML file if a pass that was expected to be completed was intercepted and acted upon differently.

Value

S3 class object.

Examples

## Not run: 
# Make a baton
baton_raw <- create_baton(bundled = TRUE,
                          bundle_params = list(dir = '/path/to/relay/raw_bundle',
                          tree = c('raw', 'processed', 'metadata', 'output')))

# Pass an empty baton for illustrative purposes
baton_raw <- relay::pass_baton(baton_raw)

# Grab the baton (if later in the script)
baton_raw <- relay::intercept_baton(baton_raw)

# Grab the baton (if in an entirely separate script/project)
baton_raw <- relay::intercept_baton(loc = '/path/to/original/baton')

## End(Not run)

al-obrien/relay documentation built on May 6, 2023, 10:19 p.m.