Skip to content

Commit

Permalink
Merge pull request #49 from getwilds/dev
Browse files Browse the repository at this point in the history
rcromwell v3.3.0 Updates
  • Loading branch information
tefirman committed Sep 17, 2024
2 parents c58df3d + 4ab55ef commit 6178c82
Show file tree
Hide file tree
Showing 53 changed files with 424 additions and 569 deletions.
16 changes: 7 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rcromwell
Title: Convenience Tools for Managing WDL Workflows via Cromwell
Version: 3.2.5
Version: 3.3.0
Authors@R: c(
person("Amy", "Paguirigan", role = "aut",
comment = c(ORCID = "0000-0002-6819-9736")),
Expand All @@ -12,30 +12,28 @@ 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:
httr,
jsonlite,
dplyr,
purrr,
tidyr,
lubridate,
rlang,
glue
glue,
curl,
httr2
License: MIT + file LICENSE
Depends: R (>= 3.6.0)
Depends: R (>= 4.1.0)
Roxygen: list(markdown = TRUE, roclets = c("collate", "namespace", "rd",
"roxyglobals::global_roclet"))
RoxygenNote: 7.3.2
Encoding: UTF-8
Suggests:
curl,
knitr,
rmarkdown,
roxyglobals,
testthat (>= 3.0.0),
vcr (>= 0.6.0),
webmockr
Remotes:
ropensci/vcr
vcr (>= 1.6.0),
webmockr (>= 1.0.0)
Config/testthat/edition: 3
Config/roxyglobals/filename: globals.R
Config/roxyglobals/unique: FALSE
Expand Down
16 changes: 9 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ export(cromwell_workflow)
export(cw_url)
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(httr,GET)
importFrom(httr,POST)
importFrom(httr,content)
importFrom(httr,status_code)
importFrom(httr,stop_for_status)
importFrom(httr,upload_file)
importFrom(httr2,req_body_multipart)
importFrom(httr2,req_error)
importFrom(httr2,req_headers)
importFrom(httr2,req_method)
importFrom(httr2,req_perform)
importFrom(httr2,req_url_query)
importFrom(httr2,request)
importFrom(httr2,resp_body_json)
importFrom(jsonlite,fromJSON)
importFrom(lubridate,now)
importFrom(lubridate,with_tz)
Expand All @@ -43,7 +46,6 @@ importFrom(purrr,map_dfr)
importFrom(purrr,pluck)
importFrom(purrr,reduce)
importFrom(rlang,abort)
importFrom(rlang,caller_env)
importFrom(rlang,has_name)
importFrom(rlang,is_character)
importFrom(rlang,is_logical)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rcromwell 3.3.0

* Swapping `httr` for `httr2` and fixing styling (@sckott in [#48](https://github.com/getwilds/rcromwell/pull/48))

# rcromwell 3.2.5

* gains new function `cromwell_labels` that hits the `/labels` route (#43) (#45)
Expand Down
6 changes: 4 additions & 2 deletions R/cromwellAbort.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
cromwell_abort <- function(workflow_id, url = cw_url(), token = NULL) {
check_url(url)
crom_mssg("Aborting job in Cromwell")
http_post(make_url(url, "api/workflows/v1", workflow_id, "abort"),
http_req_post(
url = make_url(url, "api/workflows/v1", workflow_id, "abort"),
token = token
) %>%
) |>
http_perform() |>
dplyr::as_tibble()
}
6 changes: 5 additions & 1 deletion R/cromwellBackends.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
cromwell_backends <- function(url = cw_url(), token = NULL) {
check_url(url)
crom_mssg("Getting backend options from Cromwell")
all <- http_get(make_url(url, "api/workflows/v1/backends"), token = token)
all <- http_req_get(
url = make_url(url, "api/workflows/v1/backends"),
token = token
) |>
http_perform()
all$supportedBackends <- unlist(all$supportedBackends)
return(all)
}
10 changes: 5 additions & 5 deletions R/cromwellCache.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ cromwell_cache <- function(workflow_id, url = cw_url(), token = NULL) {
}

cromwell_cache_http <- function(workflow_id, url = cw_url(), token = NULL) {
http_get(
http_req_get(
url = make_url(url, "api/workflows/v1", workflow_id, "metadata"),
query = list(expandSubWorkflows = "false"),
as = "parsed",
token = token
)
) |>
req_url_query(expandSubWorkflows = "false") |>
http_perform()
}

#' @autoglobal
Expand All @@ -50,7 +50,7 @@ cromwell_cache_process <- function(crommetadata, workflow_id) {
# add the shard Index associated
b$shardIndex <- shard_data$shardIndex
} else {
b <- dplyr::as_tibble("shardIndex" = shard_data$shardIndex)
b <- dplyr::tibble("shardIndex" = shard_data$shardIndex)
}
b$shardIndex <- as.character(b$shardIndex)
b$workflow_id <- workflow_id
Expand Down
8 changes: 4 additions & 4 deletions R/cromwellCall.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ cromwell_call <- function(workflow_id, url = cw_url(), token = NULL) {
check_url(url)
crom_mssg(glue("Querying for call metadata for workflow id: {workflow_id}"))
crommetadata <-
http_get(
http_req_get(
url = make_url(url, "api/workflows/v1", workflow_id, "metadata"),
query = list(expandSubWorkflows = "true"),
as = "parsed",
token = token
)
) |>
req_url_query(expandSubWorkflows = "true") |>
http_perform()
# if the response is a character vector, then return it and stop
if (is.character(crommetadata)) stop(crommetadata)
# if the response is a list, meaning it has some content, continue
Expand Down
8 changes: 4 additions & 4 deletions R/cromwellFailures.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ cromwell_failures <- function(workflow_id, url = cw_url(), token = NULL) {
))

response <-
http_get(
http_req_get(
url = make_url(url, "api/workflows/v1", workflow_id, "metadata"),
query = list(includeKey = "failures", includeKey = "jobId"),
as = "parsed",
token = token
)
) |>
req_url_query(includeKey = "failures", includeKey = "jobId") |>
http_perform()
cromwell_failures_process(response, workflow_id)
}

Expand Down
9 changes: 3 additions & 6 deletions R/cromwellGlob.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ cromwell_glob <- function(
check_url(url)
crom_mssg(glue("Querying for metadata for workflow id: {workflow_id}"))
url <- make_url(url, "api/workflows/v1", workflow_id, "metadata")
http_get(
url = url,
query = list(expandSubWorkflows = tolower(expand_sub_workflows)),
as = "parsed",
token = token
)
http_req_get(url = url, token = token) |>
req_url_query(expandSubWorkflows = tolower(expand_sub_workflows)) |>
http_perform()
}
10 changes: 6 additions & 4 deletions R/cromwellJobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ cromwell_jobs <- function(days = 1,
check_url(url)
crom_mssg(glue("Querying cromwell for jobs in the last {days} days"))
query <- cromwell_jobs_query(days, workflow_name, workflow_status)
jobs_data <- http_get(
make_url(url, "api/workflows/v1/query"),
query = query, token = token
)
jobs_data <- http_req_get(
url = make_url(url, "api/workflows/v1/query"),
token = token
) |>
req_url_query(!!!query) |>
http_perform()
cromwell_jobs_process(jobs_data$results)
}

Expand Down
6 changes: 3 additions & 3 deletions R/cromwellLogs.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ cromwell_logs <- function(workflow_id, url = cw_url(), token = NULL) {
}

cromwell_logs_query <- function(workflow_id, url = cw_url(), token = NULL) {
http_get(
http_req_get(
url = make_url(
url,
"api/workflows/v1",
workflow_id,
"logs"
),
as = "parsed",
token = token
)
) |>
http_perform()
}

cromwell_logs_process <- function(response, workflow_id) {
Expand Down
6 changes: 3 additions & 3 deletions R/cromwellOutputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ cromwell_outputs <- function(workflow_id, url = cw_url(), token = NULL) {
}

cromwell_outputs_query <- function(workflow_id, url = cw_url(), token = NULL) {
http_get(
http_req_get(
url =
make_url(
url,
"api/workflows/v1",
workflow_id,
"outputs"
),
as = "parsed",
token = token
)
) |>
http_perform()
}

#' @autoglobal
Expand Down
10 changes: 5 additions & 5 deletions R/cromwellSubmitBatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cromwell_submit_batch_query <- function(
)
}
body <- list(
workflowSource = httr::upload_file(wdl)
workflowSource = curl::form_file(wdl)
)

if (!is.null(params) && !is.null(batch)) {
Expand Down Expand Up @@ -78,10 +78,10 @@ cromwell_submit_batch_query <- function(
}

cromwell_submit_batch_http <- function(body, url, token) {
http_post(
http_req_post(
url = make_url(url, "api/workflows/v1"),
body = body,
encode = "multipart",
token = token
)
) |>
req_body_multipart(!!!body) |>
http_perform()
}
18 changes: 8 additions & 10 deletions R/cromwellTiming.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
#' supplied set the url as the env var `CROMWELLURL`
#' @inheritSection workflow_options Important
#' @author Amy Paguirigan, Scott Chamberlain
#' @details Internally this function uses [httr::BROWSE()] which uses
#' [utils::browseURL()] - if a auth header is required you'll have to
#' do that manually
#' @details Internally this function uses [utils::browseURL()] - if an
#' auth header is required you'll have to do that manually
#' @return Opens a timing diagram in a browser
cromwell_timing <- function(workflow_id, url = cw_url()) {
check_url(url)
crom_mssg("Getting timing diagram from Cromwell")
httr::BROWSE(
make_url(
url,
"api/workflows/v1",
workflow_id,
"timing"
)
url <- make_url(
url,
"api/workflows/v1",
workflow_id,
"timing"
)
browse(url)
}
12 changes: 6 additions & 6 deletions R/cromwellValidate.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ cromwell_validate <- function(
check_url(url)
crom_mssg("Validating a workflow for Cromwell")

body <- list(workflowSource = httr::upload_file(wdl))
body <- list(workflowSource = curl::form_file(wdl))
if (!is.null(all_inputs)) {
body <- c(
body,
workflowInputs = list(httr::upload_file(all_inputs))
workflowInputs = list(curl::form_file(all_inputs))
)
}

http_post(
http_req_post(
url = make_url(url, "api/womtool/v1/describe"),
body = body,
encode = "multipart",
token = token
)
) |>
req_body_multipart(!!!body) |>
http_perform()
}
3 changes: 2 additions & 1 deletion R/cromwellVersion.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
#' @return (character) the Cromwell version
cromwell_version <- function(url = cw_url(), token = NULL) {
check_url(url)
http_get(make_url(url, "engine/v1/version"), token = token)
http_req_get(url = make_url(url, "engine/v1/version"), token = token) |>
http_perform()
}
8 changes: 4 additions & 4 deletions R/cromwellWorkflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ cromwell_workflow <- function(workflow_id, url = cw_url(), token = NULL) {
}

cromwell_workflow_http <- function(workflow_id, url, token) {
http_get(
http_req_get(
url = make_url(url, "api/workflows/v1", workflow_id, "metadata"),
query = list(expandSubWorkflows = "false", excludeKey = "calls"),
as = "parsed",
token = token
)
) |>
req_url_query(expandSubWorkflows = "false", excludeKey = "calls") |>
http_perform()
}

cromwell_workflow_process <- function(meta, workflow_id) {
Expand Down
Loading

0 comments on commit 6178c82

Please sign in to comment.