From e98ba31243f4bc9a63198fc38e0608559323d5e3 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Fri, 12 Jul 2024 14:59:20 -0700 Subject: [PATCH 1/9] rework internals to use httr2 and dev version of webmockr that supports httr2 --- DESCRIPTION | 5 +++-- NAMESPACE | 19 +++++++++---------- R/auth.R | 25 +++++++++++-------------- R/cancel.R | 14 +++++++------- R/http.R | 17 +++++------------ R/proofr-package.R | 6 +++--- R/start.R | 16 +++++++--------- R/status.R | 13 ++++++------- R/timeout.R | 4 ++-- man/proof_header.Rd | 7 ++++--- man/proof_timeout.Rd | 4 ++-- tests/testthat/test-proof_cancel.R | 9 +++++---- tests/testthat/test-proof_header.R | 7 ++++--- tests/testthat/test-proof_start.R | 7 ++++--- tests/testthat/test-proof_status.R | 4 ++-- 15 files changed, 74 insertions(+), 83 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 53b120b..ace890c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,11 +10,11 @@ URL: http://getwilds.org/proofr/ (website) License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Imports: cli, glue, - httr + httr2 Suggests: jsonlite, knitr, @@ -22,5 +22,6 @@ Suggests: testthat (>= 3.0.0), webmockr, withr +Remotes: ropensci/webmockr@httr2 Config/testthat/edition: 3 VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index 4e55711..2a9b3c6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,13 +8,12 @@ export(proof_status) export(proof_timeout) importFrom(cli,cli_progress_bar) importFrom(cli,cli_progress_update) -importFrom(httr,DELETE) -importFrom(httr,GET) -importFrom(httr,POST) -importFrom(httr,add_headers) -importFrom(httr,content) -importFrom(httr,http_error) -importFrom(httr,http_status) -importFrom(httr,status_code) -importFrom(httr,stop_for_status) -importFrom(httr,timeout) +importFrom(httr2,req_body_json) +importFrom(httr2,req_error) +importFrom(httr2,req_headers) +importFrom(httr2,req_method) +importFrom(httr2,req_perform) +importFrom(httr2,req_timeout) +importFrom(httr2,request) +importFrom(httr2,resp_body_json) +importFrom(httr2,resp_status) diff --git a/R/auth.R b/R/auth.R index ad2046f..d32f3ba 100644 --- a/R/auth.R +++ b/R/auth.R @@ -12,11 +12,11 @@ find_token <- function(token = NULL) { #' Get header for PROOF API calls #' #' @export +#' @param req An `httr2` request. required #' @param token (character) PROOF API token. optional -#' @return A `request` S3 class with the HTTP header that can be passed -#' to `httr::GET()`, `httr::POST()`, etc. -proof_header <- function(token = NULL) { - add_headers(Authorization = paste0("Bearer ", find_token(token))) +#' @return An `httr2_request` S3 class adding an HTTP header +proof_header <- function(req, token = NULL) { + req_headers(req, Authorization = paste0("Bearer ", find_token(token))) } #' Authenticate with PROOF API @@ -31,16 +31,13 @@ proof_authenticate <- function(username, password) { assert(username, "character") assert(password, "character") - response <- POST(make_url("authenticate"), - body = list( + request(make_url("authenticate")) |> + req_body_json(list( username = username, password = password - ), - encode = "json", - timeout(proofr_env$timeout_sec) - ) - stop_for_status(response) - parsed <- content(response, as = "parsed") - token <- parsed$token - token + )) |> + req_timeout(proofr_env$timeout_sec) |> + req_perform() |> + resp_body_json() |> + {\(x) x$token}() } diff --git a/R/cancel.R b/R/cancel.R index 5bad958..889a6e6 100644 --- a/R/cancel.R +++ b/R/cancel.R @@ -9,11 +9,11 @@ #' #' If run when there's no Cromwell server running, an HTTP error proof_cancel <- function(token = NULL) { - response <- DELETE( - make_url("cromwell-server"), - proof_header(token), - timeout(proofr_env$timeout_sec) - ) - stop_for_message(response) - content(response, as = "parsed") + request(make_url("cromwell-server")) |> + req_method("DELETE") |> + proof_header(token) |> + req_timeout(proofr_env$timeout_sec) |> + req_error(body = error_body) |> + req_perform() |> + resp_body_json() } diff --git a/R/http.R b/R/http.R index c431700..bdf5497 100644 --- a/R/http.R +++ b/R/http.R @@ -1,13 +1,6 @@ -stop_for_message <- function(response) { - if (http_error(response)) { - parsed <- tryCatch(content(response), error = function(e) e) - if (inherits(parsed, "error")) stop_for_status(response) - if (!is.list(parsed)) stop_for_status(response) - msg <- glue::glue( - "{http_status(response)$reason}", - " (HTTP {status_code(response)})", - " {parsed$message}" - ) - stop(msg, call. = FALSE) - } +error_body <- function(response) { + parsed <- resp_body_json(response) + glue::glue( + "Additional context: {parsed$message}" + ) } diff --git a/R/proofr-package.R b/R/proofr-package.R index 801d48c..7744de4 100644 --- a/R/proofr-package.R +++ b/R/proofr-package.R @@ -2,8 +2,8 @@ "_PACKAGE" ## usethis namespace: start -#' @importFrom httr GET POST DELETE add_headers content -#' stop_for_status timeout http_status status_code -#' http_error +#' @importFrom httr2 request req_perform req_headers +#' req_timeout req_body_json req_method req_error +#' resp_status resp_body_json ## usethis namespace: end NULL diff --git a/R/start.R b/R/start.R index f105cc7..67fd95c 100644 --- a/R/start.R +++ b/R/start.R @@ -26,13 +26,11 @@ #' - `job_id` (character) - the job ID #' - `info` (character) - message proof_start <- function(slurm_account = NULL, token = NULL) { - response <- POST( - make_url("cromwell-server"), - proof_header(token), - body = list(slurm_account = slurm_account), - encode = "json", - timeout(proofr_env$timeout_sec) - ) - stop_for_message(response) - content(response, as = "parsed") + request(make_url("cromwell-server")) |> + req_body_json(list(slurm_account = slurm_account)) |> + proof_header(token) |> + req_timeout(proofr_env$timeout_sec) |> + req_error(body = error_body) |> + req_perform() |> + resp_body_json() } diff --git a/R/status.R b/R/status.R index 1e7761b..1e9c60a 100644 --- a/R/status.R +++ b/R/status.R @@ -25,13 +25,12 @@ proof_status <- function(wait = FALSE, token = NULL) { } fetch_status <- function(token = NULL) { - response <- GET( - make_url("cromwell-server"), - proof_header(token), - timeout(proofr_env$timeout_sec) - ) - stop_for_message(response) - content(response, as = "parsed") + request(make_url("cromwell-server")) |> + proof_header(token) |> + req_timeout(proofr_env$timeout_sec) |> + req_error(body = error_body) |> + req_perform() |> + resp_body_json() } fetch_wait <- function(token) { diff --git a/R/timeout.R b/R/timeout.R index f898e9b..6bb7941 100644 --- a/R/timeout.R +++ b/R/timeout.R @@ -2,10 +2,10 @@ #' #' @export #' @param sec (integer/numeric) number of seconds after which -#' requests will timeout. default: 5 sec (5000 ms) +#' requests will timeout. default: 10 sec (10000 ms) #' @references #' @return nothing, side effect of setting the timeout for requests -proof_timeout <- function(sec = 5) { +proof_timeout <- function(sec = 10) { assert(sec, c("integer", "numeric")) proofr_env$timeout_sec <- sec } diff --git a/man/proof_header.Rd b/man/proof_header.Rd index 13c374a..3b39591 100644 --- a/man/proof_header.Rd +++ b/man/proof_header.Rd @@ -4,14 +4,15 @@ \alias{proof_header} \title{Get header for PROOF API calls} \usage{ -proof_header(token = NULL) +proof_header(req, token = NULL) } \arguments{ +\item{req}{An \code{httr2} request. required} + \item{token}{(character) PROOF API token. optional} } \value{ -A \code{request} S3 class with the HTTP header that can be passed -to \code{httr::GET()}, \code{httr::POST()}, etc. +An \code{httr2_request} S3 class adding an HTTP header } \description{ Get header for PROOF API calls diff --git a/man/proof_timeout.Rd b/man/proof_timeout.Rd index 5dd22ab..67adb7a 100644 --- a/man/proof_timeout.Rd +++ b/man/proof_timeout.Rd @@ -4,11 +4,11 @@ \alias{proof_timeout} \title{Set the timeout for all requests to the PROOF API} \usage{ -proof_timeout(sec = 5) +proof_timeout(sec = 10) } \arguments{ \item{sec}{(integer/numeric) number of seconds after which -requests will timeout. default: 5 sec (5000 ms)} +requests will timeout. default: 10 sec (10000 ms)} } \value{ nothing, side effect of setting the timeout for requests diff --git a/tests/testthat/test-proof_cancel.R b/tests/testthat/test-proof_cancel.R index 9f864b5..5cb78f0 100644 --- a/tests/testthat/test-proof_cancel.R +++ b/tests/testthat/test-proof_cancel.R @@ -1,12 +1,12 @@ test_that("proof_cancel - success", { stub_registry_clear() - stub_request("delete", make_url("cromwell-server")) %>% + stub_request("delete", make_url("cromwell-server")) |> to_return( body = jsonlite::toJSON(response_cancel_success, auto_unbox = TRUE), status = 200L, headers = list("Content-type" = "application/json") ) - stub_registry() + # stub_registry() enable(quiet = TRUE) @@ -24,7 +24,7 @@ test_that("proof_cancel - success", { }) test_that("proof_cancel - not running, can not cancel", { - stub_request("delete", make_url("cromwell-server")) %>% + stub_request("delete", make_url("cromwell-server")) |> to_return( body = jsonlite::toJSON(response_cancel_conflict, auto_unbox = TRUE), status = 409L, @@ -34,7 +34,8 @@ test_that("proof_cancel - not running, can not cancel", { enable(quiet = TRUE) withr::with_envvar(c("PROOF_TOKEN" = "notarealtoken"), { - expect_error(proof_cancel(), "Job is not running, nothing to delete") + expect_error(proof_cancel(), "HTTP 409 Conflict") + expect_error(proof_cancel(), "Additional context") }) diff --git a/tests/testthat/test-proof_header.R b/tests/testthat/test-proof_header.R index 26f812c..bd0d08e 100644 --- a/tests/testthat/test-proof_header.R +++ b/tests/testthat/test-proof_header.R @@ -2,13 +2,14 @@ test_that("proof_header", { # errors if no env var set and no string supplied - expect_error(proof_header(), "token not found") + expect_error(proof_header(request("")), "token not found") # returns token if given - expect_match(proof_header("adf")$headers[[1]], "adf") + expect_match(proof_header(request(""), "adf")$headers[[1]], "adf") # If PROOF_TOKEN env var set, fxn can find it withr::with_envvar(c("PROOF_TOKEN" = "notarealtoken"), { - expect_match(proof_header()$headers[[1]], "notarealtoken") + expect_match(proof_header(request(""))$headers[[1]], + "notarealtoken") }) }) diff --git a/tests/testthat/test-proof_start.R b/tests/testthat/test-proof_start.R index 66e4e45..2830ec7 100644 --- a/tests/testthat/test-proof_start.R +++ b/tests/testthat/test-proof_start.R @@ -1,5 +1,5 @@ test_that("proof_start - success", { - stub_request("post", make_url("cromwell-server")) %>% + stub_request("post", make_url("cromwell-server")) |> to_return( body = jsonlite::toJSON(response_start_success, auto_unbox = TRUE), status = 200L, @@ -22,7 +22,7 @@ test_that("proof_start - success", { }) test_that("proof_start - already running", { - stub_request("post", make_url("cromwell-server")) %>% + stub_request("post", make_url("cromwell-server")) |> to_return( body = jsonlite::toJSON(response_start_conflict, auto_unbox = TRUE), status = 409L, @@ -32,7 +32,8 @@ test_that("proof_start - already running", { enable(quiet = TRUE) withr::with_envvar(c("PROOF_TOKEN" = "notarealtoken"), { - expect_error(proof_start(), "Job is already running") + expect_error(proof_start(), "409") + expect_error(proof_cancel(), "Job is already running") }) diff --git a/tests/testthat/test-proof_status.R b/tests/testthat/test-proof_status.R index e26429e..3211ba7 100644 --- a/tests/testthat/test-proof_status.R +++ b/tests/testthat/test-proof_status.R @@ -1,5 +1,5 @@ test_that("proof_status - server IS running", { - stub_request("get", make_url("cromwell-server")) %>% + stub_request("get", make_url("cromwell-server")) |> to_return( body = jsonlite::toJSON( response_status_running, @@ -30,7 +30,7 @@ test_that("proof_status - server IS running", { }) test_that("proof_status - server IS NOT running", { - stub_request("get", make_url("cromwell-server")) %>% + stub_request("get", make_url("cromwell-server")) |> to_return( body = jsonlite::toJSON( response_status_not_running, From f05bc88ab3bbe3477db4369929fe0a8c1244f0d1 Mon Sep 17 00:00:00 2001 From: Amy Paguirigan Date: Sun, 19 May 2024 20:38:55 -0700 Subject: [PATCH 2/9] Update proofr.Rmd wee tweak --- vignettes/proofr.Rmd | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/vignettes/proofr.Rmd b/vignettes/proofr.Rmd index 36d060c..6513c90 100644 --- a/vignettes/proofr.Rmd +++ b/vignettes/proofr.Rmd @@ -18,7 +18,7 @@ library(proofr) ## Authenticate with the PROOF API -Run the function `proof_authenticate()`, which calls the PROOF API with your username and password, and returns an API token (an alphanumeric string). +Run the function `proof_authenticate()`, which calls the PROOF API with your username and password, and returns an API token (an alphanumeric string). A new token is created when a new PROOF server is created, thus this API token will need to be reset. ```r @@ -29,23 +29,25 @@ my_proof_token (note: the above token is not a real token) -On your computer, save your API token as an environment variable named `PROOF_TOKEN`. +Alternatively, save your API token directly as an environment variable named `PROOF_TOKEN` so that it can be used by other `proofr` functions without exposing your token in your code. To do so run the following. -If you've saved your `PROOF_TOKEN` env var, then you can use the other `proofr` functions. - -Otherwise, you can pass your PROOF token to the `proofr` functions. If you pass your token to the functions, only do so by passing the call to `Sys.getenv` like `proof_status(token = Sys.getenv("MY_TOKEN"))`. +```r +Sys.setenv("PROOF_TOKEN" = proof_authenticate("username", "password")) +``` -## Start a Cromwell Server +## Start a PROOF Server -Start the server +Start a PROOF server ```r proof_start() ``` +Note: `proofr` assumes you only have one server running and if you've started a server using the app, you'll need to stop that server before starting one in R via `proofr`. + -Get the URL, using `wait=TRUE` so that it doesn't return data until the server is fully ready to use +Get metadata about the PROOF server you have started, including the URL of the API using `wait=TRUE` so that it doesn't return data until the server is fully ready to use. ```r @@ -54,6 +56,9 @@ cromwell_url <- metadata$cromwellUrl cromwell_url ``` + + + ## rcromwell setup Load `rcromwell` From eaa212ca0f66ceba038b51bca7dbc93c65c83efe Mon Sep 17 00:00:00 2001 From: tefirman Date: Mon, 5 Aug 2024 10:03:10 -0700 Subject: [PATCH 3/9] Removing token sentence and adding small wording fixes --- vignettes/proofr.Rmd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vignettes/proofr.Rmd b/vignettes/proofr.Rmd index 6513c90..0c49020 100644 --- a/vignettes/proofr.Rmd +++ b/vignettes/proofr.Rmd @@ -18,7 +18,7 @@ library(proofr) ## Authenticate with the PROOF API -Run the function `proof_authenticate()`, which calls the PROOF API with your username and password, and returns an API token (an alphanumeric string). A new token is created when a new PROOF server is created, thus this API token will need to be reset. +Run the function `proof_authenticate()`, which calls the PROOF API with your username and password, and returns an API token (an alphanumeric string). ```r @@ -29,7 +29,7 @@ my_proof_token (note: the above token is not a real token) -Alternatively, save your API token directly as an environment variable named `PROOF_TOKEN` so that it can be used by other `proofr` functions without exposing your token in your code. To do so run the following. +Alternatively, save your API token directly as an environment variable named `PROOF_TOKEN` so that it can be used by other `proofr` functions without exposing your token in your code. To do so, run the following: ```r Sys.setenv("PROOF_TOKEN" = proof_authenticate("username", "password")) @@ -38,16 +38,16 @@ Sys.setenv("PROOF_TOKEN" = proof_authenticate("username", "password")) ## Start a PROOF Server -Start a PROOF server +Start a PROOF server using the `proof_start()` function: ```r proof_start() ``` -Note: `proofr` assumes you only have one server running and if you've started a server using the app, you'll need to stop that server before starting one in R via `proofr`. +Note: `proofr` assumes you only have one server running; if you've started a server using the app, you'll need to stop that server before starting one in R via `proofr`. -Get metadata about the PROOF server you have started, including the URL of the API using `wait=TRUE` so that it doesn't return data until the server is fully ready to use. +Get metadata about the PROOF server you have started, including the URL of the API, using `wait=TRUE` so that it doesn't return data until the server is fully ready to use. ```r From e35f94ba17c2d97b4b43a75ec55485ef586aa761 Mon Sep 17 00:00:00 2001 From: tefirman Date: Mon, 5 Aug 2024 10:08:49 -0700 Subject: [PATCH 4/9] Fixing spacing issue identified by linting GH Action --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index fc35650..da08a5f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,7 +1,7 @@ make_url <- function(...) { proof_base <- Sys.getenv("PROOF_API_BASE_URL", - "https://proof-api.fredhutch.org") + "https://proof-api.fredhutch.org") file.path(proof_base, ...) } From fda4cbbd43f87f213e8ca9b8bf5d5e8fdb6a676b Mon Sep 17 00:00:00 2001 From: tefirman Date: Mon, 5 Aug 2024 10:27:22 -0700 Subject: [PATCH 5/9] Porting changes to proofr.Rmd.og and remade proofr.Rmd --- vignettes/proofr.Rmd | 6 +----- vignettes/proofr.Rmd.og | 16 ++++++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/vignettes/proofr.Rmd b/vignettes/proofr.Rmd index 0c49020..f295c2f 100644 --- a/vignettes/proofr.Rmd +++ b/vignettes/proofr.Rmd @@ -31,11 +31,11 @@ my_proof_token Alternatively, save your API token directly as an environment variable named `PROOF_TOKEN` so that it can be used by other `proofr` functions without exposing your token in your code. To do so, run the following: + ```r Sys.setenv("PROOF_TOKEN" = proof_authenticate("username", "password")) ``` - ## Start a PROOF Server Start a PROOF server using the `proof_start()` function: @@ -46,7 +46,6 @@ proof_start() ``` Note: `proofr` assumes you only have one server running; if you've started a server using the app, you'll need to stop that server before starting one in R via `proofr`. - Get metadata about the PROOF server you have started, including the URL of the API, using `wait=TRUE` so that it doesn't return data until the server is fully ready to use. @@ -56,9 +55,6 @@ cromwell_url <- metadata$cromwellUrl cromwell_url ``` - - - ## rcromwell setup Load `rcromwell` diff --git a/vignettes/proofr.Rmd.og b/vignettes/proofr.Rmd.og index 47af803..bb6de78 100644 --- a/vignettes/proofr.Rmd.og +++ b/vignettes/proofr.Rmd.og @@ -33,22 +33,22 @@ my_proof_token (note: the above token is not a real token) -On your computer, save your API token as an environment variable named `PROOF_TOKEN`. - -If you've saved your `PROOF_TOKEN` env var, then you can use the other `proofr` functions. - -Otherwise, you can pass your PROOF token to the `proofr` functions. If you pass your token to the functions, only do so by passing the call to `Sys.getenv` like `proof_status(token = Sys.getenv("MY_TOKEN"))`. +Alternatively, save your API token directly as an environment variable named `PROOF_TOKEN` so that it can be used by other `proofr` functions without exposing your token in your code. To do so, run the following: +```{r set-env-token} +Sys.setenv("PROOF_TOKEN" = proof_authenticate("username", "password")) +``` -## Start a Cromwell Server +## Start a PROOF Server -Start the server +Start a PROOF server using the `proof_start()` function: ```{r start} proof_start() ``` +Note: `proofr` assumes you only have one server running; if you've started a server using the app, you'll need to stop that server before starting one in R via `proofr`. -Get the URL, using `wait=TRUE` so that it doesn't return data until the server is fully ready to use +Get metadata about the PROOF server you have started, including the URL of the API, using `wait=TRUE` so that it doesn't return data until the server is fully ready to use. ```{r cromwell-url} metadata <- proof_status(wait = TRUE) From 7171223c2e418108b4b4cf66b0670685b3fc10a3 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Tue, 6 Aug 2024 11:28:43 -0700 Subject: [PATCH 6/9] update docs --- R/auth.R | 3 ++- man/proof_header.Rd | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/auth.R b/R/auth.R index d32f3ba..8df4a27 100644 --- a/R/auth.R +++ b/R/auth.R @@ -14,7 +14,8 @@ find_token <- function(token = NULL) { #' @export #' @param req An `httr2` request. required #' @param token (character) PROOF API token. optional -#' @return An `httr2_request` S3 class adding an HTTP header +#' @return An `httr2_request` S3 class adding an HTTP header for +#' `Authorization` with the value in `token` proof_header <- function(req, token = NULL) { req_headers(req, Authorization = paste0("Bearer ", find_token(token))) } diff --git a/man/proof_header.Rd b/man/proof_header.Rd index 3b39591..f5a8ad9 100644 --- a/man/proof_header.Rd +++ b/man/proof_header.Rd @@ -12,7 +12,8 @@ proof_header(req, token = NULL) \item{token}{(character) PROOF API token. optional} } \value{ -An \code{httr2_request} S3 class adding an HTTP header +An \code{httr2_request} S3 class adding an HTTP header for +\code{Authorization} with the value in \code{token} } \description{ Get header for PROOF API calls From ce8f9c37abf6daf2c81edd9c32de02097d2c6a09 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Fri, 9 Aug 2024 09:24:38 -0700 Subject: [PATCH 7/9] no longer need dev version of webmockr; tweak url formatting in desc file --- DESCRIPTION | 8 +++----- man/proofr-package.Rd | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5432e4d..ad40f27 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,11 @@ Package: proofr Title: Client for the PROOF API -Version: 0.2.0.95 +Version: 0.2.1.91 Authors@R: person("Scott", "Chamberlain", , "sachamber@fredhutch.org", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1444-9135")) Description: Client for the PROOF API. -URL: http://getwilds.org/proofr/ (website) - https://github.com/getwilds/proofr (devel) +URL: http://getwilds.org/proofr/, https://github.com/getwilds/proofr License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) @@ -20,8 +19,7 @@ Suggests: knitr, rmarkdown, testthat (>= 3.0.0), - webmockr, + webmockr (>= 1.0.0), withr -Remotes: ropensci/webmockr@httr2 Config/testthat/edition: 3 VignetteBuilder: knitr diff --git a/man/proofr-package.Rd b/man/proofr-package.Rd index 7df68ec..6d06fce 100644 --- a/man/proofr-package.Rd +++ b/man/proofr-package.Rd @@ -11,7 +11,8 @@ Client for the PROOF API. \seealso{ Useful links: \itemize{ - \item \url{http://getwilds.org/proofr/ (website) https://github.com/getwilds/proofr (devel)} + \item \url{http://getwilds.org/proofr/} + \item \url{https://github.com/getwilds/proofr} } } From 0d8f6ea8615c6130dc3c4c3c4ef8501375b70efb Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Fri, 9 Aug 2024 09:34:13 -0700 Subject: [PATCH 8/9] swap info fxn over to use httr2 --- R/info.R | 11 +++++------ tests/testthat/test-proof_info.R | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/R/info.R b/R/info.R index 78f4a59..0a1bcc7 100644 --- a/R/info.R +++ b/R/info.R @@ -9,11 +9,10 @@ #' - `commit_message` (character): the commit message of the API's most recent commit #' - `tag` (character): tag of most recent commit; if this does not contain a hyphen, it's a release version proof_info <- function() { - response <- GET( - make_url("info"), - timeout(proofr_env$timeout_sec) - ) - stop_for_message(response) - content(response, as = "parsed") + request(make_url("info")) |> + req_timeout(proofr_env$timeout_sec) |> + req_error(body = error_body) |> + req_perform() |> + resp_body_json() } diff --git a/tests/testthat/test-proof_info.R b/tests/testthat/test-proof_info.R index 1126f4c..e7819cd 100644 --- a/tests/testthat/test-proof_info.R +++ b/tests/testthat/test-proof_info.R @@ -14,6 +14,11 @@ test_that("proof_info - success", { expect_type(info_res, "list") + # also works w/o token as it's not needed for this fxn + info_res_wo_token <- proof_info() + + expect_type(info_res_wo_token, "list") + stub_registry_clear() disable(quiet = TRUE) From f64a28c0744406674c0a0535f1f60e716a444c14 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Thu, 15 Aug 2024 16:03:30 -0700 Subject: [PATCH 9/9] R 4.1.0 or greater for native pipe --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index ad40f27..685c60d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,6 +10,7 @@ License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 +Depends: R (>= 4.1.0) Imports: cli, glue,