From d755a82a8e011716b67229083fa0426cf91cc1ee Mon Sep 17 00:00:00 2001 From: Sam Albers Date: Tue, 12 Dec 2023 10:53:23 -0800 Subject: [PATCH 1/2] add information message when loading conbenchcoms --- R/conbench_info.R | 16 ++++++++++++++++ R/zzz.R | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 R/conbench_info.R create mode 100644 R/zzz.R diff --git a/R/conbench_info.R b/R/conbench_info.R new file mode 100644 index 0000000..94523a1 --- /dev/null +++ b/R/conbench_info.R @@ -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 +} diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..600e113 --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,16 @@ +.onAttach <- function(libname, pkgname) { + if (interactive()) { + load_msg <- tryCatch({ + msg <- conbench_info() + cat( + paste0( + "Conbench server information\n", + paste0(" - ", names(msg),": ", msg, collapse = "\n") + ), + "\n") + }, error = function(e) { + "No available conbench info" + }) + return(packageStartupMessage(load_msg)) + } +} From 4dcfaac6d97d15e95298ac21052acf86589db98d Mon Sep 17 00:00:00 2001 From: Sam Albers Date: Tue, 12 Dec 2023 11:03:00 -0800 Subject: [PATCH 2/2] fix msg --- NAMESPACE | 1 + R/zzz.R | 27 +++++++++++++++------------ man/conbench_info.Rd | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 man/conbench_info.Rd diff --git a/NAMESPACE b/NAMESPACE index 008942b..28948b2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/zzz.R b/R/zzz.R index 600e113..8cd4190 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,16 +1,19 @@ .onAttach <- function(libname, pkgname) { if (interactive()) { - load_msg <- tryCatch({ - msg <- conbench_info() - cat( - paste0( - "Conbench server information\n", - paste0(" - ", names(msg),": ", msg, collapse = "\n") - ), - "\n") - }, error = function(e) { - "No available conbench info" - }) - return(packageStartupMessage(load_msg)) + 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") + } + ) } } diff --git a/man/conbench_info.Rd b/man/conbench_info.Rd new file mode 100644 index 0000000..7cbb874 --- /dev/null +++ b/man/conbench_info.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/conbench_info.R +\name{conbench_info} +\alias{conbench_info} +\title{Get a list of conbench info} +\usage{ +conbench_info() +} +\value{ +the response +} +\description{ +Get a list of conbench info +}