Skip to contents

[Stable]

This function takes a list of workflows and a list of data as input. It runs each workflow and returns the results as a named list where the names of the list correspond to the workflow ID (meta$ID).

Workflows are run in the order they are provided in lWorkflows. The results from each workflow are passed as inputs (along with lData) for later workflows.

Usage

RunWorkflows(
  lWorkflows,
  lData = NULL,
  lConfig = NULL,
  bKeepInputData = FALSE,
  bReturnResult = TRUE,
  strResultNames = c("Type", "ID"),
  bContinueOnError = FALSE
)

Arguments

lWorkflows

list A named list of metadata defining how the workflow should be run.

lData

list A named list of domain-level data frames.

lConfig

list Optional configuration object passed through to RunWorkflow(). Supported hook fields:

  • LoadData: Optional function or registered provider name used before spec validation. Functions must accept lWorkflow, lConfig, and lData as named formals. workr includes a built-in "gsm.datasim" provider that reads adapter settings from lConfig$gsm.datasim.

  • SaveData: Optional function or registered provider name used before returning results when bReturnResult = TRUE. Functions must accept lWorkflow and lConfig as named formals.

bKeepInputData

boolean should the input data be included in lData after the workflow is run? Only relevant when bReturnResult is FALSE. Default is TRUE.

bReturnResult

boolean should only the result from the last step (lResults) be returned? If false, the full workflow (including lResults) is returned. Default is TRUE.

strResultNames

string vector of length two, which describes the meta fields used to name the output.

bContinueOnError

logical If TRUE, failed workflows are recorded and later workflows still run. Default FALSE retains the existing fail-fast behavior.

Value

A named list of results from RunWorkflow(), where the names correspond to the workflow ID. When bContinueOnError = TRUE, returns a summary with results, status, and failures.

Examples

sum_step <- function(x, y) {x + y}
lWorkflows <- list(
  list(
    meta = list(Type = "demo", ID = "001"),
    steps = list(
      list(name = "sum_step", output = "result", params = list(x = "value1", y = "value2"))
    )
  )
)
lData <- list(value1 = 1, value2 = 2)
RunWorkflows(lWorkflows, lData)
#> [INFO] Running 1 Workflows
#> [INFO] Initializing `demo_001` Workflow
#> [INFO] No spec found in workflow. Proceeding without checking data.
#> [INFO] Workflow Step 1 of 1: `sum_step`
#> [INFO] Evaluating 2 parameter(s) for `sum_step`
#> [INFO] x = value1: Passing lData$value1.
#> [INFO] y = value2: Passing lData$value2.
#> [INFO] Calling `sum_step`
#> Error in GetStrFunctionIfNamespaced(lStep$name): Function 'sum_step' not found.