Commit e0426883 authored by mmassaviol's avatar mmassaviol
Browse files

Add show running workflow on reload if still running

Debug on reload function (add reload off select step tools)
parent 59d255a4
......@@ -647,6 +647,7 @@ generate_pages_server <- function() {
res <- res + '\tif (!file.exists(paste0(input$results_dir,"/logs/runlog.txt"))){\n'
res <- res + '\t\tfile.create(paste0(input$results_dir,"/logs/runlog.txt"))\n'
res <- res + '\t}\n'
res <- res + '\t\tsystem(paste0("touch ",input$results_dir,"/logs/workflow.running"),wait = T)\n'
res <- res + '\t\tsystem2("python3",paste("-u -m snakemake", "-s", "/workflow/Snakefile" ,\t"--configfile", paste0(input$results_dir,"/params.yml") ,\t"-d", input$results_dir ,\t"--cores", input$cores , sep = " " ),wait = FALSE, stdout = paste0(input$results_dir,"/logs/runlog.txt"), stderr = paste0(input$results_dir,"/logs/runlog.txt"))\n'
......@@ -898,7 +899,6 @@ generate_app <- function() {
res <- res + '\tif (file.exists(paste0(dossierAnalyse,"/params.yml"))){\n'
res <- res + '\t\tparams = read_yaml(paste0(dossierAnalyse,"/params.yml"))\n'
res <- res + '\t\tfor (param in names(params$params_types)){\n'
res <- res + '\t\t\tprint(params[param])\n'
res <- res + '\t\t\tif (params$params_types[[param]] == "text"){\n'
res <- res + '\t\t\t\tupdateTextInput(session, param, value = params[[param]])\n'
res <- res + '\t\t\t}\n'
......@@ -912,6 +912,9 @@ generate_app <- function() {
res <- res + '\t\t\t\tupdateSelectInput(session, param, selected = params[[param]])\n'
res <- res + '\t\t\t}\n'
res <- res + '\t\t}\n'
res <- res + '\t\tfor (step in params$steps){\n'
res <- res + '\t\t\tupdateSelectInput(session, paste0("select",step$name), selected = params[[step$name]])\n'
res <- res + '\t\t}\n'
res <- res + '\t}\n'
res <- res + '\t# if rulegraph show it\n'
res <- res + '\trulegraph = list.files(path=dossierAnalyse,pattern="rulegraph[[:digit:]]+.svg")\n'
......@@ -929,6 +932,7 @@ generate_app <- function() {
res <- res + '\n\n'
res <- res + 'server <- function( input, output, session) {\n\n'
res <- res + '\trv <- reactiveValues(textstream = c(""), running = FALSE, timer = reactiveTimer(1000))\n\n'
# Observe query to find user and directory
res <- res + 'observeEvent(parseQueryString(session$clientData$url_search),{\n'
......@@ -949,6 +953,9 @@ generate_app <- function() {
res <- res + '\t\t\treload(dossierAnalyse,session,output)\n'
res <- res + '\t\t\tupdateTextInput(session, "results_dir", value = dossierAnalyse)\n'
res <- res + '\t\t\tshinyjs::disable("results_dir")\n'
res <- res + '\t\t\tif (file.exists(paste0(dossierAnalyse,"/logs/workflow.running"))){\n'
res <- res + '\t\t\t\trv$running = TRUE\n'
res <- res + '\t\t\t}\n'
res <- res + '\t\t}\n'
res <- res + '\t\telse{\n'
res <- res + '\t\t\t# create new dir\n'
......@@ -960,8 +967,6 @@ generate_app <- function() {
res <- res + '\t})\n'
# Observe if the workflow is running
res <- res + '\trv <- reactiveValues(textstream = c(""), running = FALSE, timer = reactiveTimer(1000))\n'
res <- res + '\n'
res <- res + '\tobserve({\n'
res <- res + '\t\trv$timer()\n'
res <- res + '\t\tif (isolate(rv$running)){\n'
......@@ -980,13 +985,13 @@ generate_app <- function() {
res <- res + '\t\t\t\taddResourcePath("results", input$results_dir)\n'
res <- res + '\t\t\t\toutUI = tags$iframe(src=paste0("/results/report.html"),width="100%", height="900px")\n'
res <- res + '\t\t\t\toutput$report_html = renderUI(outUI)\n'
res <- res + '\t\t\t\tfile.remove(paste0(paste0(input$results_dir,"/logs/workflow_end.ok")))\n'
res <- res + '\t\t\t\tfile.remove(paste0(input$results_dir,"/logs/workflow_end.ok"))\n'
res <- res + '\t\t\t}\n'
res <- res + '\t\t\telse if (file.exists(paste0(isolate(input$results_dir),"/logs/workflow_end.error"))){\n'
res <- res + '\t\t\t\trv$running = F\n'
res <- res + '\t\t\t\ttoggle_inputs(reactiveValuesToList(input),T,F)\n'
res <- res + '\t\t\t\toutput$report_html = renderUI(HTML(paste(readLines(paste0(input$results_dir,"/logs/workflow_end.error"),warn=F), collapse = "<br/>")))\n'
res <- res + '\t\t\t\tfile.remove(paste0(paste0(input$results_dir,"/logs/workflow_end.error")))\n'
res <- res + '\t\t\t\tfile.remove(paste0(input$results_dir,"/logs/workflow_end.error"))\n'
res <- res + '\t\t\t}\n'
res <- res + '\t\t\tshinyjs::runjs(\n'
res <- res + '\t\t\t\t"var objDiv = document.getElementById(\'run_out\'); objDiv.scrollTop = objDiv.scrollHeight;"\n'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment