Skip to content

Commit

Permalink
Merge pull request #23 from conbench/sam/add-retries
Browse files Browse the repository at this point in the history
Add retries to all API calls
  • Loading branch information
boshek authored Dec 12, 2023
2 parents 3afd01b + 8c6ab59 commit 55cdb12
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: conbenchcoms
Title: An API wrapper for conbench communications
Version: 0.0.9
Version: 0.0.10
Authors@R: c(
person("Jonathan", "Keane", , "[email protected]", role = c("aut", "ctb"),
comment = c(ORCID = "0000-0001-7087-9776")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(benchmark_results)
export(benchmarks)
export(compare_results)
export(compare_runs)
export(conbench_info)
export(conbench_perform)
export(conbench_request)
export(hardware)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# combenchcoms 0.0.10
* Add httr2's baked in retry strategy to all api calls

# conbenchcoms 0.0.9
* Remove `compare` function
* Add `compare_results` function (similar to old `compare` but only works for comparing benchmark results)
Expand Down
16 changes: 16 additions & 0 deletions R/conbench_info.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#' Get a list of conbench info
#'
#' @return the response
#' @export

conbench_info <- function() {
req <- req_url_path_append(conbench_request(), "ping")

resp <- conbench_perform(req)

dat <- resp_body_json(resp, simplifyVector = TRUE, flatten = TRUE)

dat[["date"]] <- NULL

dat
}
2 changes: 2 additions & 0 deletions R/session.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ conbench_perform <- function(data, ...) {
resp <- data |>
req_error(is_error = function(resp) FALSE) |>
req_headers(cookie = .conbench_session$cookie) |>
req_retry(max_tries = 5) |>
req_perform(...)

# Authenticate if we need to
Expand All @@ -25,6 +26,7 @@ conbench_perform <- function(data, ...) {
resp <- data |>
req_error(body = error_body) |>
req_headers(cookie = .conbench_session$cookie) |>
req_retry(max_tries = 5) |>
req_perform(...)

resp
Expand Down
19 changes: 19 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.onAttach <- function(libname, pkgname) {
if (interactive()) {
load_msg <- tryCatch(
{
msg <- conbench_info()
packageStartupMessage(
paste0(
"Conbench server information\n",
paste0(" - ", names(msg), ": ", msg, collapse = "\n")
),
"\n"
)
},
error = function(e) {
packageStartupMessage("No available conbench info")
}
)
}
}
14 changes: 14 additions & 0 deletions man/conbench_info.Rd

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

0 comments on commit 55cdb12

Please sign in to comment.