Skip to contents

Compares the resource dependencies in a workflow preload list to those currently avialble in the state to determine if the workflow can be run.

Usage

ASM_check_workflow(state, session, pll)

Arguments

state

ASM state from ASM_fetch_state()

session

Shiny session variable

pll

Workflow preload list.

Value

A list with the following attributes following elements:

  • isgood: Boolean indicating the exit status of the function.

  • msgs: Messages to be passed back to the user.

  • chk_msgs: Results of check, this can contain "tags()"

  • dep_table: Table of dependency information with the following columns:

    • mod_ID: The formods module ID of the module that needs the resource.

    • dep_type : Type of resource dependency currently only "ds" for data source.

    • id : The formods module ID supplying the resource.

    • res_label: The resource label.

    • res_found: Logical indicating if the resource was found or not.

Examples

# The ASM session won't have any components so the check below should fail
sess_res = ASM_test_mksession()
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → ASM:   dest:   file.path("config","report.docx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → ASM:   dest:   file.path("config","report.pptx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → ASM:   dest:   file.path("config","report.yaml")
#> → ASM: State initialized
#> → ASM: setting word placeholders: 
#> → ASM:   -> setting docx ph: HEADERLEFT = left header
#> → ASM:   -> setting docx ph: HEADERRIGHT = right header
#> → ASM:   -> setting docx ph: FOOTERLEFT = left footer
#> → ASM: module isgood: TRUE
#> → # preload_complete is good: TRUE ------------------------------------------
session = sess_res[["session"]]
state = FM_fetch_mod_state(id="ASM", session=session)

# The DW test merge should require resource labels that are not currently present
pll = formods::FM_read_yaml(system.file(package="formods", "preload", "DW_test_merge.yaml"))
#> Warning: file("") only supports open = "w+" and open = "w+b": using the former

cwf_res = ASM_check_workflow(state=state, session=session, pll=pll)

cwf_res
#> $isgood
#> [1] TRUE
#> 
#> $msgs
#> NULL
#> 
#> $chk_msgs
#> [1] "Workflow good: No resource dependencies found"
#> 
#> $dep_table
#> NULL
#>