From f6a90ec2e233f9a69bdb0bfca2a10ae8417fe139 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Fri, 26 Jul 2024 15:08:37 -0700 Subject: [PATCH 01/28] #106 add labels to Workflows Run table and shifted to left for more visibility; needs dev rcromwell --- Dockerfile | 2 +- Makefile | 2 +- app/server.R | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9df22f2..5a93d77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" -RUN R -q -e "remotes::install_github('getwilds/rcromwell@v3.2.1')" +RUN R -q -e "remotes::install_github('getwilds/rcromwell@dev')" RUN rm -rf /srv/shiny-server/ COPY app/ /srv/shiny-server/ diff --git a/Makefile b/Makefile index 0cc1453..47669d6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ RSCRIPT = Rscript --no-init-file FILE_TARGET := "${FILE}" -DEPS := $(shell ${RSCRIPT} -e 'invisible(lapply(c("glue", "cli"), require, character.only = TRUE, quiet = TRUE))' -e 'deps = renv::dependencies(quiet = TRUE)' -e 'uniq_pkgs = sort(unique(deps$$Package))' -e 'uniq_pkgs = uniq_pkgs[!grepl("^proofr$$|^rcromwell$$", uniq_pkgs)]' -e 'cat(c("getwilds/proofr@v0.2", "getwilds/rcromwell@v3.2.1", uniq_pkgs), file="deps.txt", sep="\n")') +DEPS := $(shell ${RSCRIPT} -e 'invisible(lapply(c("glue", "cli"), require, character.only = TRUE, quiet = TRUE))' -e 'deps = renv::dependencies(quiet = TRUE)' -e 'uniq_pkgs = sort(unique(deps$$Package))' -e 'uniq_pkgs = uniq_pkgs[!grepl("^proofr$$|^rcromwell$$", uniq_pkgs)]' -e 'cat(c("getwilds/proofr@v0.2", "getwilds/rcromwell@dev", uniq_pkgs), file="deps.txt", sep="\n")') run: ${RSCRIPT} -e "options(shiny.autoreload = TRUE)" \ diff --git a/app/server.R b/app/server.R index 2cc8b69..5831fa6 100644 --- a/app/server.R +++ b/app/server.R @@ -540,8 +540,17 @@ server <- function(input, output, session) { ) ) - # reorder columns + # Add workflow labels + ## Get labels data + labels_df <- lapply(workflowDat$workflow_id, \(x) { + as_tibble_row(cromwell_labels(x, url = rv$url, token = rv$token)) %>% + mutate(workflow_id = sub("cromwell-", "", workflow_id)) + }) %>% bind_rows() + workflowDat <- left_join(workflowDat, labels_df, by = "workflow_id") + ## Then reorder columns workflowDat <- dplyr::relocate(workflowDat, copyId, .after = workflow_id) + workflowDat <- dplyr::relocate(workflowDat, Label, .after = copyId) + workflowDat <- dplyr::relocate(workflowDat, secondaryLabel, .after = Label) } } else { workflowDat <- data.frame( From 74bf7bfb9756a9d1565e10f859ee8012e5b51b2b Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Fri, 26 Jul 2024 15:48:56 -0700 Subject: [PATCH 02/28] tiny change to test another commit --- app/server.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/server.R b/app/server.R index 5831fa6..a400a44 100644 --- a/app/server.R +++ b/app/server.R @@ -545,7 +545,8 @@ server <- function(input, output, session) { labels_df <- lapply(workflowDat$workflow_id, \(x) { as_tibble_row(cromwell_labels(x, url = rv$url, token = rv$token)) %>% mutate(workflow_id = sub("cromwell-", "", workflow_id)) - }) %>% bind_rows() + }) %>% + bind_rows() workflowDat <- left_join(workflowDat, labels_df, by = "workflow_id") ## Then reorder columns workflowDat <- dplyr::relocate(workflowDat, copyId, .after = workflow_id) From 783d03216495dfb35023740eefbedc69a8e04fad Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Thu, 8 Aug 2024 11:55:46 -0700 Subject: [PATCH 03/28] change rcromwell to v3.2.5 (latest release) --- Dockerfile | 2 +- Makefile | 2 +- README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5a93d77..52eb41b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" -RUN R -q -e "remotes::install_github('getwilds/rcromwell@dev')" +RUN R -q -e "remotes::install_github('getwilds/rcromwell@v3.2.5')" RUN rm -rf /srv/shiny-server/ COPY app/ /srv/shiny-server/ diff --git a/Makefile b/Makefile index 47669d6..9313c44 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ RSCRIPT = Rscript --no-init-file FILE_TARGET := "${FILE}" -DEPS := $(shell ${RSCRIPT} -e 'invisible(lapply(c("glue", "cli"), require, character.only = TRUE, quiet = TRUE))' -e 'deps = renv::dependencies(quiet = TRUE)' -e 'uniq_pkgs = sort(unique(deps$$Package))' -e 'uniq_pkgs = uniq_pkgs[!grepl("^proofr$$|^rcromwell$$", uniq_pkgs)]' -e 'cat(c("getwilds/proofr@v0.2", "getwilds/rcromwell@dev", uniq_pkgs), file="deps.txt", sep="\n")') +DEPS := $(shell ${RSCRIPT} -e 'invisible(lapply(c("glue", "cli"), require, character.only = TRUE, quiet = TRUE))' -e 'deps = renv::dependencies(quiet = TRUE)' -e 'uniq_pkgs = sort(unique(deps$$Package))' -e 'uniq_pkgs = uniq_pkgs[!grepl("^proofr$$|^rcromwell$$", uniq_pkgs)]' -e 'cat(c("getwilds/proofr@v0.2", "getwilds/rcromwell@v3.2.5", uniq_pkgs), file="deps.txt", sep="\n")') run: ${RSCRIPT} -e "options(shiny.autoreload = TRUE)" \ diff --git a/README.md b/README.md index 160bf0f..887d139 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can run this Shiny app locally. First you'll need to install required packag (note: run `make pkg_deps_cmd` to update the below code block) ```r -pak::pak(c("getwilds/proofr@v0.2", "getwilds/rcromwell@v3.2.1", "dplyr", "DT", "ggplot2", "glue", "httr", "jsonlite", "lubridate", "magrittr", "memoise", "purrr", "rclipboard", "RColorBrewer", "rlang", "shiny", "shinyBS", "shinydashboard", "shinydashboardPlus", "shinyFeedback", "shinyjs", "shinylogs", "shinyvalidate", "shinyWidgets", "testthat", "tibble", "uuid")) +pak::pak(c("getwilds/proofr@v0.2", "getwilds/rcromwell@v3.2.5", "dplyr", "DT", "ggplot2", "glue", "httr", "jsonlite", "lubridate", "magrittr", "memoise", "purrr", "rclipboard", "RColorBrewer", "rlang", "shiny", "shinyBS", "shinydashboard", "shinydashboardPlus", "shinyFeedback", "shinyjs", "shinylogs", "shinyvalidate", "shinyWidgets", "testthat", "tibble", "uuid")) ``` And the above yourself in R. From 3768daf9077bb08ba0afcb390a568040a89e6995 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Thu, 8 Aug 2024 21:08:06 -0700 Subject: [PATCH 04/28] #85 attempt to allow users to view inputs - new viewer tab to view inputs only with reactjson - replace inputs table in tracking tab with button to link to viewer tab - button in viewer tab to link back to tracking tab --- Dockerfile | 2 +- app/server.R | 45 +++++++++++++++++++++++++++++++++------------ app/sidebar.R | 10 ++++++++-- app/tab-tracking.R | 2 +- app/tab-viewer.R | 16 ++++++++++++++++ app/ui.R | 4 +++- 6 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 app/tab-viewer.R diff --git a/Dockerfile b/Dockerfile index 9df22f2..97f22d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update -y && apt-get install -y libssh-dev RUN R -q -e 'install.packages(c("ellipsis"), repos="https://cran.rstudio.com/")' RUN R -q -e 'install.packages(c("shiny"), repos="https://cran.rstudio.com/")' -RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat"), repos="https://cran.r-project.org")' +RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat", "listviewer"), repos="https://cran.r-project.org")' RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" diff --git a/app/server.R b/app/server.R index 2cc8b69..9dacb66 100644 --- a/app/server.R +++ b/app/server.R @@ -28,6 +28,8 @@ library(rcromwell) library(rclipboard) +library(listviewer) + source("sidebar.R") source("modals.R") source("proof.R") @@ -716,20 +718,39 @@ server <- function(input, output, session) { workflowInputs <- eventReactive(input$joblistCromwell_rows_selected, { print("find inputs") data <- workflowUpdate() + FOCUS_ID <- data[input$joblistCromwell_rows_selected, ]$workflow_id - as.data.frame(jsonlite::fromJSON( - cromwell_workflow(FOCUS_ID, - url = rv$url, - token = rv$token - )$inputs - )) + output$currentWorkflowId <- renderText({ + paste("Workflow ID: ", FOCUS_ID) + }) + + cromwell_workflow(FOCUS_ID, + url = rv$url, + token = rv$token + )$inputs }) - output$workflowInp <- renderDT( - data <- workflowInputs(), - class = "compact", - filter = "top", - options = list(scrollX = TRUE), selection = "single", rownames = FALSE - ) + ### inputs json javascript viewer + output$workflowInp <- renderReactjson({ + reactjson(workflowInputs()) + }) + ### edit json viewer + observeEvent(input$workflowInp_edit, { + str(input$workflowInp_edit, max.level=2) + }) + ### go to viewer tab when clicked from Tracking tab + observeEvent(input$linkToViewerTab, { + updateTabItems(session, "tabs", "viewer") + }) + ### go back to tracking tab from viewer tab + observeEvent(input$linkToTrackingTab, { + updateTabsetPanel(session, "tabs", "tracking") + }) + ### set workflow id display in viewer tab back to none + ### when nothing selected in the Workflows Run table + observeEvent(input$joblistCromwell_rows_selected, { + output$currentWorkflowId <- renderText({"Workflow ID: "}) + }, ignoreNULL = FALSE) + ## Render a list of jobs in a table for a workflow output$joblistCromwell <- renderDT({ datatable( diff --git a/app/sidebar.R b/app/sidebar.R index 9f63023..30661a7 100644 --- a/app/sidebar.R +++ b/app/sidebar.R @@ -23,6 +23,10 @@ menu_item_trouble <- menuItem("Troubleshoot", tabName = "troubleshoot", icon = icon("wrench"), badgeLabel = "troubleshoot", badgeColor = "red" ) +menu_item_viewer <- menuItem("Viewer", + tabName = "viewer", icon = icon("wrench"), + badgeLabel = "viewer", badgeColor = "purple" +) proofSidebar <- function() { sidebarMenu( @@ -32,7 +36,8 @@ proofSidebar <- function() { menu_item_validate, menu_item_submit, menu_item_track, - menu_item_trouble + menu_item_trouble, + menu_item_viewer ) } @@ -43,6 +48,7 @@ nonProofSidebar <- function() { menu_item_validate, menu_item_submit, menu_item_track, - menu_item_trouble + menu_item_trouble, + menu_item_viewer ) } diff --git a/app/tab-tracking.R b/app/tab-tracking.R index e8f66e4..4019c81 100644 --- a/app/tab-tracking.R +++ b/app/tab-tracking.R @@ -89,7 +89,7 @@ tab_tracking <- tabItem( box( width = 6, title = "Workflow Inputs", - DTOutput("workflowInp") + actionButton("linkToViewerTab", "View list") ) ), fluidRow( diff --git a/app/tab-viewer.R b/app/tab-viewer.R new file mode 100644 index 0000000..e3c1f48 --- /dev/null +++ b/app/tab-viewer.R @@ -0,0 +1,16 @@ +library(listviewer) + +tab_viewer <- tabItem( + tabName = "viewer", + fluidRow( + box( + title = "View Workflow Inputs", + width = 12, + textOutput("currentWorkflowId"), + p(""), + actionButton("linkToTrackingTab", "Back to Track Jobs Tab"), + p(""), + reactjsonOutput("workflowInp", height = "100%") + ) + ) +) diff --git a/app/ui.R b/app/ui.R index cd14f8d..b5702a3 100644 --- a/app/ui.R +++ b/app/ui.R @@ -20,6 +20,7 @@ source("tab-validate.R") source("tab-submission.R") source("tab-tracking.R") source("tab-troubleshoot.R") +source("tab-viewer.R") source("sidebar.R") ui <- dashboardPage( @@ -52,7 +53,8 @@ ui <- dashboardPage( tab_validate, tab_submission, tab_tracking, - tab_troublehsoot + tab_troublehsoot, + tab_viewer ) ) ) From 976c431fff454b1588bc3ad7e729c3677a0882e4 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Tue, 13 Aug 2024 12:55:56 -0700 Subject: [PATCH 05/28] #118 trying out cookies again so that sessions persist with page reloads and closed tabs/windows --- Dockerfile | 4 ++- app/cookies-db.R | 56 ++++++++++++++++++++++++++++++++++++++++++ app/server.R | 31 ++++++++++++++++++++++- app/ui.R | 64 +++++++++++++++++++++++++----------------------- 4 files changed, 123 insertions(+), 32 deletions(-) create mode 100644 app/cookies-db.R diff --git a/Dockerfile b/Dockerfile index 9df22f2..566a231 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,14 @@ RUN apt-get update -y && apt-get install -y libssh-dev RUN R -q -e 'install.packages(c("ellipsis"), repos="https://cran.rstudio.com/")' RUN R -q -e 'install.packages(c("shiny"), repos="https://cran.rstudio.com/")' -RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat"), repos="https://cran.r-project.org")' +RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat", "cookies"), repos="https://cran.r-project.org")' RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" RUN R -q -e "remotes::install_github('getwilds/rcromwell@v3.2.1')" +ADD .my.cnf /root/ + RUN rm -rf /srv/shiny-server/ COPY app/ /srv/shiny-server/ # COPY ./shiny-server.conf /etc/shiny-server/ diff --git a/app/cookies-db.R b/app/cookies-db.R new file mode 100644 index 0000000..c66fb45 --- /dev/null +++ b/app/cookies-db.R @@ -0,0 +1,56 @@ +library(RMariaDB) +library(DBI) + +COOKIE_EXPIRY_DAYS <- 1 + +to_base64 <- function(x) { + base64enc::base64encode(charToRaw(x)) +} +from_base64 <- function(x) { + rawToChar(base64enc::base64decode(x)) +} + +db <- dbConnect(RMariaDB::MariaDB(), group = "shinycromwell") +if (!dbExistsTable(db, "users")) { + db_columns <- c( + user = "TEXT", + proof_token = "TEXT", + cromwell_url = "TEXT", + login_time = "TEXT" + ) + dbCreateTable(db, "users", db_columns) +} +dbDisconnect(db) + +make_db_con <- function() { + dbConnect(RMariaDB::MariaDB(), group = "shinycromwell") +} + +user_from_db <- function(user, conn = make_db_con(), expiry = COOKIE_EXPIRY_DAYS) { + on.exit(dbDisconnect(conn)) + dbReadTable(conn, "users") %>% + as_tibble() %>% + filter( + user == user, + login_time > now() - days(expiry) + ) %>% + arrange(desc(login_time)) +} +user_to_db <- function(user, token, url, conn = make_db_con()) { + on.exit(dbDisconnect(conn)) + tibble( + user = user, + proof_token = token, + cromwell_url = url, + login_time = as.character(now()) + ) %>% + dbWriteTable(conn, "users", ., append = TRUE) +} +user_drop_from_db <- function(user, conn = make_db_con()) { + on.exit(dbDisconnect(conn)) + sql_delete <- glue::glue_sql(" + DELETE from users + WHERE user = {user} + ", .con = conn) + dbSendQuery(conn, sql_delete) +} diff --git a/app/server.R b/app/server.R index 2cc8b69..6ad42e6 100644 --- a/app/server.R +++ b/app/server.R @@ -28,6 +28,8 @@ library(rcromwell) library(rclipboard) +library(cookies) + source("sidebar.R") source("modals.R") source("proof.R") @@ -37,6 +39,7 @@ source("tab-servers.R") source("tab-welcome.R") source("validators.R") source("inputs_utils.R") +source("cookies-db.R") SANITIZE_ERRORS <- FALSE PROOF_TIMEOUT <- 20 @@ -66,7 +69,7 @@ server <- function(input, output, session) { ') }) - rv <- reactiveValues(token = "", url = "", validateFilepath="", own = FALSE) + rv <- reactiveValues(token = "", url = "", validateFilepath="", own = FALSE, user = "") rv_file <- reactiveValues( validatewdlFile_state = NULL, @@ -84,6 +87,19 @@ server <- function(input, output, session) { showModal(loginModal()) }) + observeEvent(cookies::get_cookie("user"), { + rv$user <- cookies::get_cookie("user") + print(rv$user) + user_df <- user_from_db(rv$user) %>% top_n(1) + if (nrow(user_df)) { + rv$url <- from_base64(user_df$cromwell_url) + rv$token <- from_base64(user_df$proof_token) + } + if (is.null(input$username)) { + output$userName <- renderText({ rv$user }) + } + }) + output$userName <- renderText({ input$username }) @@ -125,6 +141,14 @@ server <- function(input, output, session) { showModal(loginModal(failed = TRUE, error = try_auth$message)) } else { rv$token <- try_auth + rv$user <- input$username + cookies::set_cookie( + cookie_name = "user", + cookie_value = rv$user, + expiration = COOKIE_EXPIRY_DAYS, + secure_only = TRUE, + same_site = "strict" + ) cromwell_up <- tryCatch( proof_status(token = rv$token)$jobStatus, error = function(e) e @@ -135,6 +159,9 @@ server <- function(input, output, session) { rv$url <- proof_wait_for_up(rv$token) } } + + user_to_db(rv$user, to_base64(rv$token), to_base64(rv$url)) + removeModal() } } else { @@ -194,6 +221,8 @@ server <- function(input, output, session) { # Handle logout for both buttons observeEvent(input$proofAuthLogout, { + user_drop_from_db(rv$user) + cookies::remove_cookie("user") session$reload() }) diff --git a/app/ui.R b/app/ui.R index cd14f8d..7b762b3 100644 --- a/app/ui.R +++ b/app/ui.R @@ -13,6 +13,8 @@ library(lubridate) library(rclipboard) +library(cookies) + source("ui_components.R") source("tab-welcome.R") source("tab-servers.R") @@ -22,37 +24,39 @@ source("tab-tracking.R") source("tab-troubleshoot.R") source("sidebar.R") -ui <- dashboardPage( - skin = "black", - dashboardHeader( - title = tagList( - span(class = "logo-lg", h4(HTML("Fred Hutch
PROOF Dashboard"))), - img(src = "fred-hutch.svg") +ui <- cookies::add_cookie_handlers( + dashboardPage( + skin = "black", + dashboardHeader( + title = tagList( + span(class = "logo-lg", h4(HTML("Fred Hutch
PROOF Dashboard"))), + img(src = "fred-hutch.svg") + ), + dropdown_user_name, + dropdown_own_cromwell, + dropdown_loginout, + dropdown_help, + dropdown_src + ), + dashboardSidebar( + sidebarMenuOutput("uiSideBar") ), - dropdown_user_name, - dropdown_own_cromwell, - dropdown_loginout, - dropdown_help, - dropdown_src - ), - dashboardSidebar( - sidebarMenuOutput("uiSideBar") - ), - dashboardBody( - tags$head(tags$title("PROOF")), - tags$script("document.title = 'PROOF';"), - shinyjs::useShinyjs(), - rclipboard::rclipboardSetup(), - enter_to_click, - tooltip_style, - google_analytics, - tabItems( - tab_welcome, - tab_servers, - tab_validate, - tab_submission, - tab_tracking, - tab_troublehsoot + dashboardBody( + tags$head(tags$title("PROOF")), + tags$script("document.title = 'PROOF';"), + shinyjs::useShinyjs(), + rclipboard::rclipboardSetup(), + enter_to_click, + tooltip_style, + google_analytics, + tabItems( + tab_welcome, + tab_servers, + tab_validate, + tab_submission, + tab_tracking, + tab_troublehsoot + ) ) ) ) From c9b1c96d226bc0b6bb7d9fafb7cca4c06cabb0a8 Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Thu, 15 Aug 2024 13:16:16 -0700 Subject: [PATCH 06/28] add deploy_review_image task --- .gitlab-ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e72c471..fe79fbe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,6 +55,16 @@ test: docker run -w /srv/shiny-server --rm sc-registry.fredhutch.org/shiny-cromwell:test R -q -e 'testthat::test_dir("tests")' +deploy_review_image: + stage: deploy + except: + refs: + - main + - dev + script: + - docker tag sc-registry.fredhutch.org/shiny-cromwell:test nexus-registry.fredhutch.org/scicomp-nexus/${CI_PROJECT_NAME}:${CI_COMMIT_BRANCH} + - docker push nexus-registry.fredhutch.org/scicomp-nexus/${CI_PROJECT_NAME}:${CI_COMMIT_BRANCH} + deploy_preview: stage: deploy only: From cf19ae39c91dd7a7483be9c1ebccbb8e393cc813 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Thu, 15 Aug 2024 13:55:35 -0700 Subject: [PATCH 07/28] need timelyportfolio/reactR for the viewer functionality --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 97f22d3..20b725f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,8 @@ RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" RUN R -q -e "remotes::install_github('getwilds/rcromwell@v3.2.1')" +RUN R -q -e "remotes::install_github('timelyportfolio/reactR')" + RUN rm -rf /srv/shiny-server/ COPY app/ /srv/shiny-server/ # COPY ./shiny-server.conf /etc/shiny-server/ From 967627ca4ce9fbb39d0672840854d3fa8dcd01a6 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Fri, 16 Aug 2024 11:55:28 -0700 Subject: [PATCH 08/28] new make command to run a remote branch via a prebuilt docker image --- Makefile | 5 +++++ README.md | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Makefile b/Makefile index 9313c44..a8af8fc 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,11 @@ run_docker: docker build --platform linux/amd64 -t shiny-cromwell:app . docker run --rm -it -p 3838:3838 shiny-cromwell:app +# use: `make branch=inputs-viewer run_branch` +run_branch: + docker pull nexus-registry.fredhutch.org/scicomp-nexus/shiny-cromwell:$(branch) + docker run --rm -it -p 3838:3838 nexus-registry.fredhutch.org/scicomp-nexus/shiny-cromwell:$(branch) + # use: `make style_file FILE=stuff.R` # accepts 1 file only style_file: diff --git a/README.md b/README.md index 887d139..355b16c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,19 @@ Note that CTRL+C doesn't work to kill the container after running `make run_dock Also note that docker commands can be specific to the host operating system, so if you run into errors you may need to modify the docker commands. +#### Run a feature branch locally + +The make command `make run_branch` will run a remote branch locally on your machine. Whereas `make run_docker` runs the current branch you're on, `make run_branch` pulls down a docker image of the remote branch specified and runs that. + +Make sure to run `docker login nexus-registry.fredhutch.org` before you try this make command. You only need to run this once. + +A full example: `make branch=inputs-viewer run_branch` + +Note that the branch specification has to be before the target name (`run_branch`). + +You must be on FH campus or be on a VPN to use this make command. + + ### Debugging - Use print statements as needed ... From 6fbee05b629a3ca721400f354467106ab28d781e Mon Sep 17 00:00:00 2001 From: dtenenba Date: Fri, 16 Aug 2024 13:17:49 -0700 Subject: [PATCH 09/28] add capability to convert wdl to mermaid --- .gitlab-ci.yml | 9 +++++++++ Dockerfile | 5 ++++- app/utils.R | 12 ++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e72c471..3f83280 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,6 +54,15 @@ test: curl -sI http://shiny-cromwell:3838 | head -1 | grep -q "200 OK" docker run -w /srv/shiny-server --rm sc-registry.fredhutch.org/shiny-cromwell:test R -q -e 'testthat::test_dir("tests")' +deploy_review_image: + stage: deploy + except: + refs: + - main + - dev + script: + - docker tag sc-registry.fredhutch.org/shiny-cromwell:test nexus-registry.fredhutch.org/scicomp-nexus/${CI_PROJECT_NAME}:${CI_COMMIT_BRANCH} + - docker push nexus-registry.fredhutch.org/scicomp-nexus/${CI_PROJECT_NAME}:${CI_COMMIT_BRANCH} deploy_preview: stage: deploy diff --git a/Dockerfile b/Dockerfile index 52eb41b..27d44ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM fredhutch/r-shiny-server-base:4.3.2 -RUN apt-get update -y && apt-get install -y libssh-dev +RUN apt-get update -y && apt-get install -y libssh-dev python3-pip git RUN R -q -e 'install.packages(c("ellipsis"), repos="https://cran.rstudio.com/")' RUN R -q -e 'install.packages(c("shiny"), repos="https://cran.rstudio.com/")' @@ -10,6 +10,9 @@ RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" RUN R -q -e "remotes::install_github('getwilds/rcromwell@v3.2.5')" +# python wdl2mermaid setup: +RUN pip install git+https://github.com/chanzuckerberg/miniwdl-viz.git + RUN rm -rf /srv/shiny-server/ COPY app/ /srv/shiny-server/ # COPY ./shiny-server.conf /etc/shiny-server/ diff --git a/app/utils.R b/app/utils.R index 790f430..19040f4 100644 --- a/app/utils.R +++ b/app/utils.R @@ -70,3 +70,15 @@ abbreviate <- function(x, last = 100) { if (nchar(x) < 100) return(x) paste0(substring(x, 1, last), " ...") } + +wdl2mermaid <- function(wdlFileName) { + outfile <- tempfile(pattern = "wdl2mermaid", fileext = ".mermaid") + system2( + "wdl_to_mermaid", + args = c(shQuote(wdlFileName), "--print-flowchart"), + stdout = outfile + ) + ret <- readLines(outfile) + unlink(outfile) + paste(ret, collapse = "\n") +} \ No newline at end of file From 216ad3fc884d9024e78ecf054110146b3769db96 Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Fri, 16 Aug 2024 15:04:22 -0700 Subject: [PATCH 10/28] document how to get docker registry credentials --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 355b16c..f63f17c 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Also note that docker commands can be specific to the host operating system, so The make command `make run_branch` will run a remote branch locally on your machine. Whereas `make run_docker` runs the current branch you're on, `make run_branch` pulls down a docker image of the remote branch specified and runs that. Make sure to run `docker login nexus-registry.fredhutch.org` before you try this make command. You only need to run this once. +Contact `scicomp` to get the username and password for this step. A full example: `make branch=inputs-viewer run_branch` From 95c640df96f12cd85f78c429eb9d6a6a1eda36da Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 19 Aug 2024 09:50:04 -0700 Subject: [PATCH 11/28] fix #121 help - change from emailing to opening an issue in help dropdown --- app/ui_components.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/ui_components.R b/app/ui_components.R index 04af4d6..0bfcc81 100644 --- a/app/ui_components.R +++ b/app/ui_components.R @@ -1,15 +1,15 @@ help_html <- helpText( - HTML('Need Help?: + HTML('Need Help?


- Problem? Bug? Send an email to scicomp@fredhutch.org + Problem? Bug? Open an issue


Discussion/Questions
- Slack #workflow-managers channel + Slack #workflow-managers channel
- Email wilds@fredhutch.org + Email wilds@fredhutch.org

') From bbec01553b5427542ef42fa7e92776da4d9adec0 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 19 Aug 2024 15:25:11 -0700 Subject: [PATCH 12/28] build on dans work: new tab for wdl viewing, click to go to wdl and make mermaid --- app/server.R | 24 +++++++++++++++++++++++- app/sidebar.R | 10 ++++++++-- app/tab-tracking.R | 3 +++ app/tab-wdl.R | 6 ++++++ app/ui.R | 7 ++++++- app/utils.R | 32 +++++++++++++++++++++++++++++++- 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 app/tab-wdl.R diff --git a/app/server.R b/app/server.R index a400a44..87f898b 100644 --- a/app/server.R +++ b/app/server.R @@ -540,6 +540,14 @@ server <- function(input, output, session) { ) ) + # Add go to WDL viewer button + workflowDat <- workflowDat %>% + rowwise() %>% + mutate( + wdl = make_wdlbtn(workflow_id) + ) %>% + ungroup() + # Add workflow labels ## Get labels data labels_df <- lapply(workflowDat$workflow_id, \(x) { @@ -549,7 +557,8 @@ server <- function(input, output, session) { bind_rows() workflowDat <- left_join(workflowDat, labels_df, by = "workflow_id") ## Then reorder columns - workflowDat <- dplyr::relocate(workflowDat, copyId, .after = workflow_id) + workflowDat <- dplyr::relocate(workflowDat, wdl, .after = workflow_id) + workflowDat <- dplyr::relocate(workflowDat, copyId, .after = wdl) workflowDat <- dplyr::relocate(workflowDat, Label, .after = copyId) workflowDat <- dplyr::relocate(workflowDat, secondaryLabel, .after = Label) } @@ -566,6 +575,19 @@ server <- function(input, output, session) { ignoreNULL = TRUE ) + observeEvent(input$wdlview_btn, { + mermaid_file <- wdl_to_file( + workflow_id = strsplit(input$wdlview_btn, "_")[[1]][2], + url = rv$url, + token = rv$token + ) + mermaid_str <- wdl2mermaid(mermaid_file) + output$mermaid_diagram <- renderUI({ + mermaid_container(mermaid_str) + }) + updateTabItems(session, "tabs", "wdl") + }) + callDurationUpdate <- eventReactive(input$trackingUpdate, { stop_safe_loggedin_serverup(rv$url, rv$token, rv$own) diff --git a/app/sidebar.R b/app/sidebar.R index 9f63023..12ad610 100644 --- a/app/sidebar.R +++ b/app/sidebar.R @@ -23,6 +23,10 @@ menu_item_trouble <- menuItem("Troubleshoot", tabName = "troubleshoot", icon = icon("wrench"), badgeLabel = "troubleshoot", badgeColor = "red" ) +menu_item_wdl <- menuItem("WDL", + tabName = "wdl", icon = icon("wrench"), + badgeLabel = "wdl", badgeColor = "light-blue" +) proofSidebar <- function() { sidebarMenu( @@ -32,7 +36,8 @@ proofSidebar <- function() { menu_item_validate, menu_item_submit, menu_item_track, - menu_item_trouble + menu_item_trouble, + menu_item_wdl ) } @@ -43,6 +48,7 @@ nonProofSidebar <- function() { menu_item_validate, menu_item_submit, menu_item_track, - menu_item_trouble + menu_item_trouble, + menu_item_wdl ) } diff --git a/app/tab-tracking.R b/app/tab-tracking.R index e8f66e4..4dc0d7d 100644 --- a/app/tab-tracking.R +++ b/app/tab-tracking.R @@ -84,6 +84,9 @@ tab_tracking <- tabItem( box( width = 6, title = "Workflow Options", + actionButton(inputId = "wdlview", + label = bsicons::bs_icon("search"), + class = "btn-sm"), DTOutput("workflowOpt") ), box( diff --git a/app/tab-wdl.R b/app/tab-wdl.R new file mode 100644 index 0000000..8b13809 --- /dev/null +++ b/app/tab-wdl.R @@ -0,0 +1,6 @@ +tab_wdl <- tabItem( + tabName = "wdl", + fluidPage( + uiOutput("mermaid_diagram") + ) +) diff --git a/app/ui.R b/app/ui.R index cd14f8d..c38fa06 100644 --- a/app/ui.R +++ b/app/ui.R @@ -20,6 +20,7 @@ source("tab-validate.R") source("tab-submission.R") source("tab-tracking.R") source("tab-troubleshoot.R") +source("tab-wdl.R") source("sidebar.R") ui <- dashboardPage( @@ -43,6 +44,9 @@ ui <- dashboardPage( tags$script("document.title = 'PROOF';"), shinyjs::useShinyjs(), rclipboard::rclipboardSetup(), + tags$head( + tags$script(src = "https://cdn.jsdelivr.net/npm/mermaid@10.9.1/dist/mermaid.min.js") + ), enter_to_click, tooltip_style, google_analytics, @@ -52,7 +56,8 @@ ui <- dashboardPage( tab_validate, tab_submission, tab_tracking, - tab_troublehsoot + tab_troublehsoot, + tab_wdl ) ) ) diff --git a/app/utils.R b/app/utils.R index 19040f4..5621998 100644 --- a/app/utils.R +++ b/app/utils.R @@ -66,11 +66,30 @@ make_copybtn <- function(x, clip_prefix, tooltip) { ) } +make_wdlbtn <- function(workflow_id) { + as.character( + actionButton( + inputId = glue("wdlview_{workflow_id}"), + label = bsicons::bs_icon("search"), + class = "btn-sm", + onclick = 'Shiny.setInputValue(\"wdlview_btn\", this.id, {priority: \"event\"})' + ) + ) +} + abbreviate <- function(x, last = 100) { if (nchar(x) < 100) return(x) paste0(substring(x, 1, last), " ...") } +wdl_to_file <- function(workflow_id, url, token) { + glob <- cromwell_glob(workflow_id, url = url, token = token) + wdl_str <- glob$submittedFiles$workflow + tfile <- tempfile(pattern = "wdlize_wdl", fileext = ".wdl") + cat(wdl_str, "\n", file = tfile) + return(tfile) +} + wdl2mermaid <- function(wdlFileName) { outfile <- tempfile(pattern = "wdl2mermaid", fileext = ".mermaid") system2( @@ -81,4 +100,15 @@ wdl2mermaid <- function(wdlFileName) { ret <- readLines(outfile) unlink(outfile) paste(ret, collapse = "\n") -} \ No newline at end of file +} + +mermaid_container <- function(code) { + tags$div( + id = "mermaid-container", + tags$div(id = "mermaid-diagram", `class` = "mermaid", width = "auto", height = "auto", HTML(code)), + tags$script(HTML(" + mermaid.initialize({ startOnLoad: true }); + mermaid.init(undefined, '#mermaid-diagram'); + ")) + ) +} From c4e3f1d4620513b8b3772bfa782b47848b258926 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 19 Aug 2024 15:40:45 -0700 Subject: [PATCH 13/28] tickle shiny app build, last one failed From 96b646a2dade29bef506432ca00243063eac7fd4 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 19 Aug 2024 15:53:15 -0700 Subject: [PATCH 14/28] install and use bsicons --- Dockerfile | 2 +- app/tab-tracking.R | 1 + app/utils.R | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 27d44ba..265e724 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update -y && apt-get install -y libssh-dev python3-pip git RUN R -q -e 'install.packages(c("ellipsis"), repos="https://cran.rstudio.com/")' RUN R -q -e 'install.packages(c("shiny"), repos="https://cran.rstudio.com/")' -RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat"), repos="https://cran.r-project.org")' +RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat", "bsicons"), repos="https://cran.r-project.org")' RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" diff --git a/app/tab-tracking.R b/app/tab-tracking.R index 4dc0d7d..8fc3573 100644 --- a/app/tab-tracking.R +++ b/app/tab-tracking.R @@ -1,4 +1,5 @@ source("ui_components.R") +library(bsicons) tab_tracking <- tabItem( tabName = "tracking", diff --git a/app/utils.R b/app/utils.R index 5621998..2f762fb 100644 --- a/app/utils.R +++ b/app/utils.R @@ -1,4 +1,5 @@ library(memoise) +library(bsicons) # coerce dates to PT from UTC as_pt <- function(x) { From 5dbfa56ec52a2f60de39a9e96db9ceb2fb60166a Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Tue, 20 Aug 2024 08:51:00 -0700 Subject: [PATCH 15/28] use venv; temporarily disable docker build cache --- .gitlab-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f83280..161da2e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,9 @@ variables: before_script: - apk update - apk --no-cache add py3-pip python3 curl - - pip3 install pyyaml --break-system-packages + - python3 -m venv $HOME/.venv + - export PATH=$HOME/.venv/bin:$PATH + - pip3 install pyyaml - curl -O https://raw.githubusercontent.com/FredHutch/swarm-build-helper/main/build_helper.py # below is from https://stackoverflow.com/a/65810302/470769 - mkdir -p $HOME/.docker @@ -27,7 +29,7 @@ build: script: | python3 build_helper.py docker-compose.yml --fluentd-logging > /dev/null echo $DB_CONFIG | base64 -d > .my.cnf - docker build \ + docker build --no-cache \ -t sc-registry.fredhutch.org/shiny-cromwell:test \ --build-arg CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH} \ --build-arg CI_COMMIT_SHA=${CI_COMMIT_SHA} \ From 6beb00349720c87dd3f076f2a55936d7a947c6e4 Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Tue, 20 Aug 2024 09:13:45 -0700 Subject: [PATCH 16/28] turn docker build caching back on --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 161da2e..6848259 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ build: script: | python3 build_helper.py docker-compose.yml --fluentd-logging > /dev/null echo $DB_CONFIG | base64 -d > .my.cnf - docker build --no-cache \ + docker build \ -t sc-registry.fredhutch.org/shiny-cromwell:test \ --build-arg CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH} \ --build-arg CI_COMMIT_SHA=${CI_COMMIT_SHA} \ From 2feb6404f8ff3f9a19412a84fd0f2c567ee7408e Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Tue, 20 Aug 2024 09:45:28 -0700 Subject: [PATCH 17/28] add --no-cache back in --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6848259..161da2e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ build: script: | python3 build_helper.py docker-compose.yml --fluentd-logging > /dev/null echo $DB_CONFIG | base64 -d > .my.cnf - docker build \ + docker build --no-cache \ -t sc-registry.fredhutch.org/shiny-cromwell:test \ --build-arg CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH} \ --build-arg CI_COMMIT_SHA=${CI_COMMIT_SHA} \ From e7f1a3350ac5781be2d172d25482071d2642be68 Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Wed, 21 Aug 2024 13:25:15 -0700 Subject: [PATCH 18/28] remove redundant lines --- .gitlab-ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe79fbe..20cb449 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,11 +12,6 @@ before_script: - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json - set -x -stages: - - build - - test - - deploy - stages: - build - test From 76d77a99adbfa776b0135209bf46bf2084c86c50 Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Wed, 21 Aug 2024 15:05:19 -0700 Subject: [PATCH 19/28] add infrastructure to deploy review images --- .gitlab-ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e72c471..c27d5a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,11 +12,6 @@ before_script: - echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json - set -x -stages: - - build - - test - - deploy - stages: - build - test @@ -54,6 +49,15 @@ test: curl -sI http://shiny-cromwell:3838 | head -1 | grep -q "200 OK" docker run -w /srv/shiny-server --rm sc-registry.fredhutch.org/shiny-cromwell:test R -q -e 'testthat::test_dir("tests")' +deploy_review_image: + stage: deploy + except: + refs: + - main + - dev + script: + - docker tag sc-registry.fredhutch.org/shiny-cromwell:test nexus-registry.fredhutch.org/scicomp-nexus/${CI_PROJECT_NAME}:${CI_COMMIT_BRANCH} + - docker push nexus-registry.fredhutch.org/scicomp-nexus/${CI_PROJECT_NAME}:${CI_COMMIT_BRANCH} deploy_preview: stage: deploy From 6673dc103942c7b902974314a5ba00fa599d48ba Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Wed, 21 Aug 2024 20:31:15 -0700 Subject: [PATCH 20/28] install rmariadb and dbi in dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ea49f83..3f06302 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update -y && apt-get install -y libssh-dev RUN R -q -e 'install.packages(c("ellipsis"), repos="https://cran.rstudio.com/")' RUN R -q -e 'install.packages(c("shiny"), repos="https://cran.rstudio.com/")' -RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat", "cookies"), repos="https://cran.r-project.org")' +RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat", "cookies", "RMariaDB", "DBI"), repos="https://cran.r-project.org")' RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" From 62ca55fda2ca6372a28ab5a1ba380fb68768a7f2 Mon Sep 17 00:00:00 2001 From: dtenenba Date: Wed, 21 Aug 2024 20:41:35 -0700 Subject: [PATCH 21/28] install libmariadb-dev --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3f06302..13b622e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM fredhutch/r-shiny-server-base:4.3.2 -RUN apt-get update -y && apt-get install -y libssh-dev +RUN apt-get update -y && apt-get install -y libssh-dev libmariadb-dev RUN R -q -e 'install.packages(c("ellipsis"), repos="https://cran.rstudio.com/")' RUN R -q -e 'install.packages(c("shiny"), repos="https://cran.rstudio.com/")' From a8372f0bbcd97f663cc68eed45434617ad1737b7 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 26 Aug 2024 13:10:44 -0700 Subject: [PATCH 22/28] added button to go back to tracking tab from WDL tab --- app/server.R | 5 +++++ app/tab-wdl.R | 1 + 2 files changed, 6 insertions(+) diff --git a/app/server.R b/app/server.R index 87f898b..0554a60 100644 --- a/app/server.R +++ b/app/server.R @@ -588,6 +588,11 @@ server <- function(input, output, session) { updateTabItems(session, "tabs", "wdl") }) + ### go back to tracking tab from wdl tab + observeEvent(input$linkToTrackingTab, { + updateTabsetPanel(session, "tabs", "tracking") + }) + callDurationUpdate <- eventReactive(input$trackingUpdate, { stop_safe_loggedin_serverup(rv$url, rv$token, rv$own) diff --git a/app/tab-wdl.R b/app/tab-wdl.R index 8b13809..88b968b 100644 --- a/app/tab-wdl.R +++ b/app/tab-wdl.R @@ -1,6 +1,7 @@ tab_wdl <- tabItem( tabName = "wdl", fluidPage( + actionButton("linkToTrackingTab", "Back to Track Jobs Tab"), uiOutput("mermaid_diagram") ) ) From 7a65c792de6daaaa0443402e1bdbf920bf034188 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Tue, 27 Aug 2024 16:08:56 -0700 Subject: [PATCH 23/28] changed expiration to 2 weeks from 1 day --- app/cookies-db.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/cookies-db.R b/app/cookies-db.R index c66fb45..9ad536b 100644 --- a/app/cookies-db.R +++ b/app/cookies-db.R @@ -1,7 +1,7 @@ library(RMariaDB) library(DBI) -COOKIE_EXPIRY_DAYS <- 1 +COOKIE_EXPIRY_DAYS <- 14 to_base64 <- function(x) { base64enc::base64encode(charToRaw(x)) From 17631500e3e8f5655d597627e8903fe057b2b5fb Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Wed, 28 Aug 2024 15:06:25 -0700 Subject: [PATCH 24/28] change dbSendQuery to dbGetQuery so that delete data works --- app/cookies-db.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/cookies-db.R b/app/cookies-db.R index 9ad536b..0cf9285 100644 --- a/app/cookies-db.R +++ b/app/cookies-db.R @@ -52,5 +52,5 @@ user_drop_from_db <- function(user, conn = make_db_con()) { DELETE from users WHERE user = {user} ", .con = conn) - dbSendQuery(conn, sql_delete) + dbGetQuery(conn, sql_delete) } From 6910766b20c700cc73ab5925d01ba80b6cb7512c Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Wed, 28 Aug 2024 15:08:15 -0700 Subject: [PATCH 25/28] use cookie from browser only if its not null and has data from DB; and dont set username in UI via cookie in case cookie hangs around after logout --- app/server.R | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/server.R b/app/server.R index fcb1fb2..1cb7dca 100644 --- a/app/server.R +++ b/app/server.R @@ -90,14 +90,15 @@ server <- function(input, output, session) { observeEvent(cookies::get_cookie("user"), { rv$user <- cookies::get_cookie("user") - print(rv$user) - user_df <- user_from_db(rv$user) %>% top_n(1) - if (nrow(user_df)) { - rv$url <- from_base64(user_df$cromwell_url) - rv$token <- from_base64(user_df$proof_token) - } - if (is.null(input$username)) { - output$userName <- renderText({ rv$user }) + # print(rv$user) + # print(nchar(rv$user)) + if (!is.null(rv$user)) { + user_df <- user_from_db(rv$user) %>% top_n(1) + if (nrow(user_df)) { + #print(user_df) + rv$url <- from_base64(user_df$cromwell_url) + rv$token <- from_base64(user_df$proof_token) + } } }) From e7a6b88d502fb2b5550761157662c91e202cac21 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Thu, 29 Aug 2024 13:46:53 -0700 Subject: [PATCH 26/28] cookies funs: - use bang bang in dplyr NSE string so that we get the value of user - drop from db: use dbExecute instead of dbGetQuery as per warning - user add to db: new drop_existing param to drop existing rows of the user before adding --- app/cookies-db.R | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/cookies-db.R b/app/cookies-db.R index 0cf9285..df3d267 100644 --- a/app/cookies-db.R +++ b/app/cookies-db.R @@ -31,13 +31,22 @@ user_from_db <- function(user, conn = make_db_con(), expiry = COOKIE_EXPIRY_DAYS dbReadTable(conn, "users") %>% as_tibble() %>% filter( - user == user, + # !! needed to get the value of the variable + user == !!user, login_time > now() - days(expiry) ) %>% arrange(desc(login_time)) } -user_to_db <- function(user, token, url, conn = make_db_con()) { +user_to_db <- function(user, token, url, drop_existing = FALSE, conn = make_db_con()) { on.exit(dbDisconnect(conn)) + # drop before inserting so we only have 1 row/user + if (drop_existing) { + # don't drop if user is empty + if (nzchar(user)) { + # don't disconnect from within drop fun + user_drop_from_db(user, disconnect = FALSE, conn = conn) + } + } tibble( user = user, proof_token = token, @@ -46,11 +55,13 @@ user_to_db <- function(user, token, url, conn = make_db_con()) { ) %>% dbWriteTable(conn, "users", ., append = TRUE) } -user_drop_from_db <- function(user, conn = make_db_con()) { - on.exit(dbDisconnect(conn)) +user_drop_from_db <- function(user, disconnect = TRUE, conn = make_db_con()) { + if (disconnect) { + on.exit(dbDisconnect(conn)) + } sql_delete <- glue::glue_sql(" DELETE from users WHERE user = {user} ", .con = conn) - dbGetQuery(conn, sql_delete) + dbExecute(conn, sql_delete) } From ac3e8cc7fa2fa0e9e199065509a9c7a2d715e4ca Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Thu, 29 Aug 2024 13:48:24 -0700 Subject: [PATCH 27/28] put back showing username from cookie if input is empty; in login block move cookie add after DB insert and drop existing rows of same user first --- app/server.R | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/app/server.R b/app/server.R index 1cb7dca..58d439c 100644 --- a/app/server.R +++ b/app/server.R @@ -90,20 +90,27 @@ server <- function(input, output, session) { observeEvent(cookies::get_cookie("user"), { rv$user <- cookies::get_cookie("user") - # print(rv$user) - # print(nchar(rv$user)) + # print(glue("in observeEvent(cookies::get_cookie(user) -----> {rv$user}")) if (!is.null(rv$user)) { user_df <- user_from_db(rv$user) %>% top_n(1) if (nrow(user_df)) { - #print(user_df) + # print(user_df) rv$url <- from_base64(user_df$cromwell_url) rv$token <- from_base64(user_df$proof_token) + } else { + # force reload b/c no data from the user in the DB, so need to re-login + # cookies::remove_cookie("user") + # session$reload() } } }) output$userName <- renderText({ - input$username + if (is.null(input$username)) { + rv$user + } else { + input$username + } }) observe({ @@ -144,13 +151,7 @@ server <- function(input, output, session) { } else { rv$token <- try_auth rv$user <- input$username - cookies::set_cookie( - cookie_name = "user", - cookie_value = rv$user, - expiration = COOKIE_EXPIRY_DAYS, - secure_only = TRUE, - same_site = "strict" - ) + cromwell_up <- tryCatch( proof_status(token = rv$token)$jobStatus, error = function(e) e @@ -162,7 +163,20 @@ server <- function(input, output, session) { } } - user_to_db(rv$user, to_base64(rv$token), to_base64(rv$url)) + user_to_db( + user = rv$user, + token = to_base64(rv$token), + url = to_base64(rv$url), + drop_existing = TRUE + ) + + cookies::set_cookie( + cookie_name = "user", + cookie_value = rv$user, + expiration = COOKIE_EXPIRY_DAYS, + secure_only = TRUE, + same_site = "strict" + ) removeModal() } From 6cc61b556711630707f2a7d00fbc18834a187684 Mon Sep 17 00:00:00 2001 From: tefirman Date: Mon, 16 Sep 2024 23:26:09 -0700 Subject: [PATCH 28/28] Upping the versions of proofr and rcromwell --- Dockerfile | 4 ++-- Makefile | 2 +- README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a4ae91f..50154f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,9 +6,9 @@ RUN R -q -e 'install.packages(c("ellipsis"), repos="https://cran.rstudio.com/")' RUN R -q -e 'install.packages(c("shiny"), repos="https://cran.rstudio.com/")' RUN R -q -e 'install.packages(c("shinyFeedback", "shinyWidgets", "shinydashboard", "shinydashboardPlus", "ssh", "remotes", "markdown", "lubridate", "jsonlite", "dplyr", "DT", "glue", "httr", "purrr", "RColorBrewer", "rlang", "shinyBS", "shinyjs", "tidyverse", "uuid", "memoise", "rclipboard", "shinyvalidate", "shinylogs", "testhat", "bsicons", "listviewer", "cookies", "RMariaDB", "DBI"), repos="https://cran.r-project.org")' -RUN R -q -e "remotes::install_github('getwilds/proofr@v0.2')" +RUN R -q -e "remotes::install_github('getwilds/proofr@v0.3.0')" -RUN R -q -e "remotes::install_github('getwilds/rcromwell@v3.2.5')" +RUN R -q -e "remotes::install_github('getwilds/rcromwell@v3.3.0')" ADD .my.cnf /root/ diff --git a/Makefile b/Makefile index a8af8fc..4133ccb 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ RSCRIPT = Rscript --no-init-file FILE_TARGET := "${FILE}" -DEPS := $(shell ${RSCRIPT} -e 'invisible(lapply(c("glue", "cli"), require, character.only = TRUE, quiet = TRUE))' -e 'deps = renv::dependencies(quiet = TRUE)' -e 'uniq_pkgs = sort(unique(deps$$Package))' -e 'uniq_pkgs = uniq_pkgs[!grepl("^proofr$$|^rcromwell$$", uniq_pkgs)]' -e 'cat(c("getwilds/proofr@v0.2", "getwilds/rcromwell@v3.2.5", uniq_pkgs), file="deps.txt", sep="\n")') +DEPS := $(shell ${RSCRIPT} -e 'invisible(lapply(c("glue", "cli"), require, character.only = TRUE, quiet = TRUE))' -e 'deps = renv::dependencies(quiet = TRUE)' -e 'uniq_pkgs = sort(unique(deps$$Package))' -e 'uniq_pkgs = uniq_pkgs[!grepl("^proofr$$|^rcromwell$$", uniq_pkgs)]' -e 'cat(c("getwilds/proofr@v0.3.0", "getwilds/rcromwell@v3.3.0", uniq_pkgs), file="deps.txt", sep="\n")') run: ${RSCRIPT} -e "options(shiny.autoreload = TRUE)" \ diff --git a/README.md b/README.md index f63f17c..2998a56 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You can run this Shiny app locally. First you'll need to install required packag (note: run `make pkg_deps_cmd` to update the below code block) ```r -pak::pak(c("getwilds/proofr@v0.2", "getwilds/rcromwell@v3.2.5", "dplyr", "DT", "ggplot2", "glue", "httr", "jsonlite", "lubridate", "magrittr", "memoise", "purrr", "rclipboard", "RColorBrewer", "rlang", "shiny", "shinyBS", "shinydashboard", "shinydashboardPlus", "shinyFeedback", "shinyjs", "shinylogs", "shinyvalidate", "shinyWidgets", "testthat", "tibble", "uuid")) +pak::pak(c("getwilds/proofr@v0.3.0", "getwilds/rcromwell@v3.3.0", "dplyr", "DT", "ggplot2", "glue", "httr", "jsonlite", "lubridate", "magrittr", "memoise", "purrr", "rclipboard", "RColorBrewer", "rlang", "shiny", "shinyBS", "shinydashboard", "shinydashboardPlus", "shinyFeedback", "shinyjs", "shinylogs", "shinyvalidate", "shinyWidgets", "testthat", "tibble", "uuid")) ``` And the above yourself in R.