Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Aug 9, 2024
2 parents e060b34 + c58df3d commit 8ac98e7
Show file tree
Hide file tree
Showing 20 changed files with 138 additions and 18 deletions.
12 changes: 4 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
Package: rcromwell
Title: Convenience Tools for Managing WDL Workflows via Cromwell
Version: 3.2.4.91
Version: 3.2.6.9100
Authors@R: c(
person("Amy", "Paguirigan", role = "aut",
comment = c(ORCID = "0000-0002-6819-9736")),
person("Scott", "Chamberlain", , "sachamber@fredhutch.org", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-1444-9135")),
person("Fred Hutchinson Cancer Center", , , "wilds@fredhutch.org", role = "fnd")
)
URL: http://getwilds.org/rcromwell/ (website)
https://github.com/getwilds/rcromwell (devel)
URL: https://getwilds.org/rcromwell, https://github.com/getwilds/rcromwell
BugReports: https://github.com/getwilds/rcromwell/issues
Description: A repo containing a basic R package for using Cromwell with WDL workflows via R.
Imports:
Expand All @@ -33,11 +32,8 @@ Suggests:
rmarkdown,
roxyglobals,
testthat (>= 3.0.0),
vcr (>= 0.6.0),
webmockr
Remotes:
ropensci/vcr@httr2,
ropensci/webmockr@httr2
vcr (>= 1.6.0),
webmockr (>= 1.0.0)
Config/testthat/edition: 3
Config/roxyglobals/filename: globals.R
Config/roxyglobals/unique: FALSE
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export(workflow_inputs)
export(workflow_options)
importFrom(curl,form_file)
importFrom(dplyr,"%>%")
importFrom(dplyr,any_of)
importFrom(dplyr,as_tibble)
importFrom(dplyr,relocate)
importFrom(dplyr,tibble)
importFrom(glue,glue)
importFrom(httr2,req_body_multipart)
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# rcromwell 3.2.5

* gains new function `cromwell_labels` that hits the `/labels` route (#43) (#45)
* remove comment about failures not working (#35)
* add prior art section to readme with one entry (#30)
* reorder output columns of `cromwell_workflow` and always return tibble for `cromwell_call` (#42) (#46)
* better links in readme to docs (#41)

# rcromwell 3.2.1

* fix `cromwell_submit_batch` - internally changed `workflow_options` to `workflowOptions` (#32)
Expand Down
2 changes: 1 addition & 1 deletion R/cromwellCall.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions R/cromwellJobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,12 @@ 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)
}
6 changes: 5 additions & 1 deletion R/cromwellSubmitBatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ cromwell_submit_batch_query <- function(
)
}
if (!is.null(labels)) {
labels_temp_file <- tempfile(pattern = "rcromwell_", fileext = ".json")
cat(jsonlite::toJSON(as.list(labels), auto_unbox = TRUE),
file = labels_temp_file
)
body <- c(body,
labels = list(jsonlite::toJSON(as.list(labels), auto_unbox = TRUE))
labels = lst_upload_file(labels_temp_file)
)
}
body
Expand Down
2 changes: 1 addition & 1 deletion R/rcromwell-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## usethis namespace: start
#' @importFrom glue glue
#' @importFrom rlang abort
#' @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
#' @importFrom httr2 request req_headers req_perform req_error
Expand Down
6 changes: 5 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pak::pak("getwilds/rcromwell")

## Documentation

Go to <http://getwilds.org/rcromwell/> for `rcromwell` package documentation. Go to the **Get Started** vignette to get started!
Go to <http://getwilds.org/rcromwell/> for `rcromwell` package documentation. Go to the [Get Started vignette](https://getwilds.org/rcromwell/articles/rcromwell.html) to get started, or [reference page](https://getwilds.org/rcromwell/reference/index.html) for the function documentation.

## Bugs? Features?

Expand All @@ -48,3 +48,7 @@ Please note that the rcromwell project is released with a [Contributor Code of C
## License

[MIT](LICENSE.md)

## Prior art

- [wdlRunR](https://github.com/seandavi/wdlRunR) - archived package/repo
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pak::pak("getwilds/rcromwell")

## Documentation

Go to <http://getwilds.org/rcromwell/> for `rcromwell` package documentation. Go to the **Get Started** vignette to get started!
Go to <http://getwilds.org/rcromwell/> for `rcromwell` package documentation. Go to the [Get Started vignette](https://getwilds.org/rcromwell/articles/rcromwell.html) to get started, or [reference page](https://getwilds.org/rcromwell/reference/index.html) for the function documentation.

## Bugs? Features?

Expand All @@ -40,3 +40,7 @@ Please note that the rcromwell project is released with a [Contributor Code of C
## License

[MIT](LICENSE.md)

## Prior art

- [wdlRunR](https://github.com/seandavi/wdlRunR) - archived package/repo
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ reference:
- cromwell_failures
- cromwell_glob
- cromwell_jobs
- cromwell_labels
- cromwell_logs
- cromwell_outputs
- cromwell_submit_batch
Expand Down
3 changes: 3 additions & 0 deletions man/cromwell_labels.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/rcromwell-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions tests/fixtures/cromwell_labels_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
http_interactions:
- request:
method: get
uri: http://localhost:8000/api/workflows/v1/287c7902-abc0-49ab-a6ec-0ce0c097b4d2/labels
body:
encoding: ''
string: ''
headers:
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: 200
category: Success
reason: OK
message: 'Success: (200) OK'
headers:
server: akka-http/10.1.15
date: Fri, 26 Jul 2024 19:26:12 GMT
content-type: application/json
content-length: '200'
body:
encoding: ''
file: no
string: '{"id":"287c7902-abc0-49ab-a6ec-0ce0c097b4d2","labels":{"Label":"Apple","secondaryLabel":"Orange","workflowType":"AppSubmission","cromwell-workflow-id":"cromwell-287c7902-abc0-49ab-a6ec-0ce0c097b4d2"}}'
recorded_at: 2024-07-26 19:26:12 GMT
recorded_with: vcr/1.6.0, webmockr/1.0.0
30 changes: 30 additions & 0 deletions tests/fixtures/cromwell_labels_submit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
http_interactions:
- request:
method: post
uri: http://localhost:8000/api/workflows/v1
body:
encoding: ''
string: workflowSource=list(path = "/Users/schambe3/github/getwilds/rcromwell/inst/examples/hello.wdl",
type = "application/octet-stream", name = NULL),workflowInputs=list(path =
"/Users/schambe3/github/getwilds/rcromwell/inst/examples/inputs.json", type
= "application/json", name = NULL),labels=list(path = "/private/var/folders/qt/fzq1m_bj2yb_7b2jz57s9q7c0000gp/T/Rtmp21huqY/rcromwell_1609933b0cbaf.json",
type = "application/json", name = NULL)
headers:
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: 201
category: Success
reason: Created
message: 'Success: (201) Created'
headers:
server: akka-http/10.1.15
date: Fri, 26 Jul 2024 19:25:52 GMT
content-type: application/json
content-length: '66'
body:
encoding: ''
file: no
string: '{"id":"287c7902-abc0-49ab-a6ec-0ce0c097b4d2","status":"Submitted"}'
recorded_at: 2024-07-26 19:25:52 GMT
recorded_with: vcr/1.6.0, webmockr/1.0.0
8 changes: 8 additions & 0 deletions tests/testthat/helper-vcr.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ file_workflow_opts <- sys_file("examples/workflow_options.json")

# suppress messages for the test run
cromwell_config(verbose = FALSE)

cromwell_localhost_up <- function() {
try8000 <- tryCatch(
curl::curl_fetch_memory("localhost:8000"),
error = function(e) e
)
!inherits(try8000, "error")
}
1 change: 1 addition & 0 deletions tests/testthat/test-cromwell_call.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ test_that("cromwell_call", {
})

expect_s3_class(res, "data.frame")
expect_s3_class(res, "tbl")
expect_equal(res$callName, "hello")
})
4 changes: 0 additions & 4 deletions tests/testthat/test-cromwell_failures.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# FIXME: cromwell_failures doesn't appear to be working. At least for the
# case where data is in the $failures slot at the top level of the list
# the parsing code doesn't grab it - perhaps the API response has changed

test_that("cromwell_failures", {
vcr::use_cassette("cromwell_failures_prep", {
job <- cromwell_submit_batch(wdl = file_hello, params = file_inputs_bad)
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-cromwell_jobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
24 changes: 24 additions & 0 deletions tests/testthat/test-cromwell_labels.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
test_that("cromwell_labels", {
my_labels <- data.frame(
"workflowType" = "AppSubmission",
"Label" = "Apple",
"secondaryLabel" = "Orange"
)

vcr::use_cassette("cromwell_labels_submit", {
res <- cromwell_submit_batch(
wdl = file_hello, params = file_inputs,
labels = my_labels
)
})

# Sys.sleep(20) # Needed only for recording new fixture #nolint

vcr::use_cassette("cromwell_labels_data", {
labels_from_workflow <- cromwell_labels(res$id)
})

expect_length(labels_from_workflow, 4)
expect_equal(labels_from_workflow$Label, "Apple")
expect_equal(labels_from_workflow$secondaryLabel, "Orange")
})
2 changes: 2 additions & 0 deletions tests/testthat/test-error-handling.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not(cromwell_localhost_up())

test_that("proof api or DIY cromwell server down", {
# This should happen whether proof or DIY if not on
# campus or VPN for Fred Hutch at least
Expand Down

0 comments on commit 8ac98e7

Please sign in to comment.