From 5d1bac3ddc39fa94e431827ff6ed914ec03771d0 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Wed, 7 Aug 2024 09:33:03 -0700 Subject: [PATCH 1/2] #42 make sure cromwell_call outputs a tbl --- R/cromwellCall.R | 2 +- tests/testthat/test-cromwell_call.R | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/R/cromwellCall.R b/R/cromwellCall.R index 0092d61..ca3b45d 100644 --- a/R/cromwellCall.R +++ b/R/cromwellCall.R @@ -252,6 +252,6 @@ cromwell_call <- function(workflow_id, url = cw_url(), token = NULL) { # with Shiny apps easier just_calls <- dplyr::tibble("workflow_id" = "No call metadata available.") } - return(just_calls) + return(dplyr::as_tibble(just_calls)) } # nolint end diff --git a/tests/testthat/test-cromwell_call.R b/tests/testthat/test-cromwell_call.R index 5548c33..2189494 100644 --- a/tests/testthat/test-cromwell_call.R +++ b/tests/testthat/test-cromwell_call.R @@ -10,5 +10,6 @@ test_that("cromwell_call", { }) expect_s3_class(res, "data.frame") + expect_s3_class(res, "tbl") expect_equal(res$callName, "hello") }) From 3d38856e2c11f0a8850f0611edfcbf205a7d1c88 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Wed, 7 Aug 2024 09:55:48 -0700 Subject: [PATCH 2/2] fix #42 reorder cromwell_jobs columns to make output easier to read, bump pkg version --- DESCRIPTION | 2 +- NAMESPACE | 2 ++ R/cromwellJobs.R | 5 +++++ R/rcromwell-package.R | 2 +- tests/testthat/test-cromwell_jobs.R | 3 +++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a641f55..d28c43c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rcromwell Title: Convenience Tools for Managing WDL Workflows via Cromwell -Version: 3.2.4 +Version: 3.2.4.9200 Authors@R: c( person("Amy", "Paguirigan", role = "aut", comment = c(ORCID = "0000-0002-6819-9736")), diff --git a/NAMESPACE b/NAMESPACE index dd9d319..9bda273 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -20,7 +20,9 @@ export(cw_url) export(workflow_inputs) export(workflow_options) importFrom(dplyr,"%>%") +importFrom(dplyr,any_of) importFrom(dplyr,as_tibble) +importFrom(dplyr,relocate) importFrom(dplyr,tibble) importFrom(glue,glue) importFrom(httr,GET) diff --git a/R/cromwellJobs.R b/R/cromwellJobs.R index 74d8d61..764f3fd 100644 --- a/R/cromwellJobs.R +++ b/R/cromwellJobs.R @@ -104,5 +104,10 @@ cromwell_jobs_process <- function(jobs_data) { } else { cr_table <- dplyr::tibble("workflow_id" = NA) } + + # specific column order if columns exist (via `any_of`) + columns_order <- c("workflow_name", "workflow_id", "status", "submission", "start", + "end", "workflowDuration") + cr_table <- dplyr::relocate(cr_table, any_of(columns_order)) return(cr_table) } diff --git a/R/rcromwell-package.R b/R/rcromwell-package.R index 41bb2f4..8c2d7a3 100644 --- a/R/rcromwell-package.R +++ b/R/rcromwell-package.R @@ -3,7 +3,7 @@ ## usethis namespace: start #' @importFrom glue glue -#' @importFrom dplyr as_tibble tibble %>% +#' @importFrom dplyr as_tibble tibble relocate any_of %>% #' @importFrom lubridate now with_tz ymd_hms #' @importFrom purrr discard flatten keep map map_dfr pluck reduce ## usethis namespace: end diff --git a/tests/testthat/test-cromwell_jobs.R b/tests/testthat/test-cromwell_jobs.R index b86b0ba..99568ef 100644 --- a/tests/testthat/test-cromwell_jobs.R +++ b/tests/testthat/test-cromwell_jobs.R @@ -6,6 +6,9 @@ test_that("cromwell_jobs", { match_requests_on = c("method", "host", "path") ) + expect_s3_class(res, "data.frame") expect_s3_class(res, "tbl") expect_equal(NCOL(res), 8) + # explicit column ordering for better understanding + expect_equal(names(res)[1], "workflow_name") })