create_baton: Create a baton

View source: R/constructor.R

create_batonR Documentation

Create a baton

Description

create_baton is a constructor of an S3 class used for tracking workflows.

Usage

create_baton(
  content = list(),
  loc = NULL,
  auto_assign = FALSE,
  envir = .GlobalEnv,
  bundled = FALSE,
  bundle_params = list()
)

Arguments

content

A list of custom content that the baton should carry.

loc

The location of the associated YAML file (defaults to a temporary location).

auto_assign

Boolean value to determine if name assignment is to be automatic).

envir

Environment where auto_assign should write to.

bundled

Boolean value to determine if the baton should be created within a bundle; default is set to FALSE.

bundle_params

List of parameters to pass to create_bundle.

Details

By default, the content of the baton will be empty, only the metadata will be populated. The S3 object created will have an associated YAML file made, in a temporary location if no set location provided to loc. There is also the ability to automatically assign the S3 object to the R environment in case that is easier to remember. Some behavior can be controlled by global options, such as the referee and relay type.

The metadata of a bundle includes the following:

  1. id: unique ID of baton based upon time stamp and random numbers.

  2. referee: defines the threshold of content to write to the logbook, 'TRACE' is the lowest and the default; can be set by global setting, options(relay_referee = "TRACE").

  3. relay_type: defines the type of baton as one of 'CANCELLED', 'PRACTICE', or 'COMPETITION' (default); can be set by global setting, options(relay_type = "COMPETITION").

  4. relay_start: time stamp when baton first created (matched ID).

  5. relay_finish: time the baton was last passed (will not be populated if in middle of pass).

  6. all_grabs: time stamps for all grabs or intercepts that occurred (excludes initial creation time).

  7. all_passes: time stamps for all completed passes.

  8. pass_complete: whether or not the baton completed its latest pass.

  9. passes_completed: the number of successful passes completed.

  10. location: where the baton YAML file has been saved.

  11. dropped: boolean value of whether the baton has been dropped, signalling and end to the relay.

The logbook operates with write_logbook and read_logbook, which help track the baton without having to write contents or update the metadata.

Value

S3 class object.

Note

Although some generics (summary.baton) are used in {relay}, most functions just check for the class and do not proceed unless it is a baton. This may be rewritten to use only generics or R6 classes but right now this hybrid approach was used for simplicity.

Examples

## Not run: 
my_baton <- create_baton(loc = file.path('path', 'to', 'save', 'yaml'))

## End(Not run)

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