Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retries to all API calls #23

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading