Skip to content

Commit

Permalink
Finshed off the run workflow portion
Browse files Browse the repository at this point in the history
  • Loading branch information
john-harrold committed Nov 27, 2024
1 parent 02755fb commit c75677b
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 15 deletions.
66 changes: 52 additions & 14 deletions R/UD_Server.R
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ UD_Server <- function(id,
div(style="display:inline-block;width:100%", htmlOutput(NS(id, "ui_ud_load_data"))),
htmlOutput(NS(id, "ui_ud_clean")),
htmlOutput(NS(id, "ui_ud_select_sheets")),
htmlOutput(NS(id, "ui_ud_workflows")),
div(style="display:inline-block;vertical-align:top;width:40px", uiele_code_button),
htmlOutput(NS(id, "ui_ud_text_load_result")))

Expand Down Expand Up @@ -625,23 +626,19 @@ UD_fetch_state = function(id, id_ASM, input, session, FM_yaml_file, MOD_yaml_fi
}

#---------------------------------------------
# Saving the state
FM_set_mod_state(session, id, state)
# Running workflows

if("btn_run_wf" %in% changed_uis){
load_msg = c()
rwf_isgood = TRUE
wfn = state[["UD"]][["ui"]][["workflow"]]
wfl = state[["yaml"]][["FM"]][["workflows"]][[wfn]]

if(wfl[["require_ds"]] & !state[["UD"]][["isgood"]]){
# To run this workflow a dataset is required but one has not been
# uploaded.
state[["UD"]][["load_msg"]] = state[["MC"]][["errors"]][["no_ds_for_workflow"]]

state = FM_set_notification(state,
notify_text = state[["MC"]][["errors"]][["no_ds_for_workflow_short"]],
notify_id = "workflow_not_run",
type = "failure")

load_msg = state[["MC"]][["errors"]][["no_ds_for_workflow"]]
rwf_isgood = FALSE
FM_set_mod_state(session, id, state)
} else {
FM_le(state, paste0("Running workflow (", wfn, "): ", wfl[["desc"]]))
Expand All @@ -661,19 +658,60 @@ UD_fetch_state = function(id, id_ASM, input, session, FM_yaml_file, MOD_yaml_fi

# Appending the current state:
pll = c(res_mpl[["yaml_list"]], pll)
}

# Writing the new workflow yaml list
browser()

# Preloading the app
}
ASM_state = FM_fetch_mod_state(id=state[["MC"]][["module"]][["depends"]][["id_ASM"]], session=session)

if(is.null(ASM_state)){
load_msg = state[["MC"]][["errors"]][["no_asm_state"]]
rwf_isgood = FALSE
} else {
# Writing the new workflow yaml list to a save file:
ssf = tempfile(fileext=".zip")
ss_res = ASM_save_state(state=state, session=session, file_path=ssf, pll=pll)
if(ss_res[["isgood"]]){
FM_pause_screen(state = state,
message = state[["MC"]][["labels"]][["busy"]][["rwf"]],
session = session)
ls_res =
ASM_load_state(state, session,
file_path = ssf)
FM_resume_screen(state = state,
session = session)


state = ls_res[["state"]]

if(!ls_res[["isgood"]]){
load_msg = c(state[["MC"]][["errors"]][["ls_failed"]], ls_res[["msgs"]])
rwf_isgood = FALSE
}

} else {
load_msg = c(state[["MC"]][["errors"]][["ss_failed"]], ss_res[["msgs"]])
rwf_isgood = FALSE
}
}
}


if(rwf_isgood){
state = FM_set_notification(state,
notify_text = state[["MC"]][["labels"]][["rwf_success"]],
notify_id = "rwf_success",
type = "success")
} else {
state = FM_set_notification(state,
notify_text = state[["MC"]][["errors"]][["rwf_failed"]],
notify_id = "rwf_failed",
type = "failure")
}
state[["UD"]][["load_msg"]] = paste0(load_msg, collapse="\n")
}

# Saving the state
FM_set_mod_state(session, id, state)

# Returning the state
state}

Expand Down
7 changes: 7 additions & 0 deletions inst/templates/UD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ MC:
tab_code: "Code"
tab_preview: "Data preview"
switch_clean: "Clean column names on upload"
rwf_success: "Workflow complete."
busy:
rwf: "Running workflow be patient."
# In the following you can use placeholder for the follwing:
# ===EXT=== Uploaded file extension
# ===FILE=== Loaded file name
Expand All @@ -31,6 +34,10 @@ MC:
no_workflows_found: "No valid workflows have been found"
no_ds_for_workflow: "The selected workflow requires a dataset. Please upload a dataset first then run the workflow."
no_ds_for_workflow_short: "Workflow not run, no dataset."
no_asm_state: "Unable to read ASM state."
ss_failed: "Unable to save workflow file."
ls_failed: "Unable to load workflow file."
rwf_failed: "Workflow failed."
tooltips:
# Set to FALSE to disable tool tips for this module
include: TRUE
Expand Down
9 changes: 8 additions & 1 deletion inst/templates/UD_module_components.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@ server <- function(input, output, session) {
# changes in the module state outside of the module
react_FM = reactiveValues()

# This is the list of module ids used for reproducable script generation. The
# order here is important.
mod_ids = c("UD", "DW", "FG")

# Module server
ASM_Server(id="ASM", react_state=react_FM, mod_ids=mod_ids)

# Module server
UD_Server(id="UD", react_state=react_FM)
UD_Server(id="UD", id_ASM="ASM", react_state=react_FM)

# Current state outside of the module
output$ui_state = renderText({
Expand Down

0 comments on commit c75677b

Please sign in to comment.