From e669cd7d669b49d43fbb3ab48bd2f346377eb7f0 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Mon, 3 Jul 2023 11:28:28 -0700 Subject: [PATCH 1/3] feat: API key rollout is done! no warning errors --- R/epidatacall.R | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/R/epidatacall.R b/R/epidatacall.R index 7b855b79..ca88d8e8 100644 --- a/R/epidatacall.R +++ b/R/epidatacall.R @@ -184,22 +184,6 @@ fetch_classic <- function(epidata_call, fields = NULL, disable_data_frame_parsin response <- request_impl(epidata_call, "classic", fields) response_content <- httr::content(response, as = "text", encoding = "UTF-8") - # TODO Temporary workaround the first row of the response being a comment - # Remove on 2023-06-21 - if (grepl("This request exceeded", response_content) && !epidata_call$only_supports_classic) { - response_content <- jsonlite::fromJSON(response_content, simplifyDataFrame = FALSE) - message <- response_content$epidata[[1L]] - cli::cli_abort(c( - "epidata warning, promoted to error: {message}", - "i" = "Either:", - "*" = "set the environment variable DELPHI_EPIDATA_KEY, or", - "*" = 'set the option "delphi.epidata.key":', - " " = '{.code options(delphi.epidata.key = "YOUR_KEY_OR_TEMP_KEY")}', - "To save your key for later sessions (and hide it from your code), you can edit your .Renviron file with:", - "*" = "usethis::edit_r_environ()" - )) - } - response_content <- jsonlite::fromJSON(response_content, simplifyDataFrame = !disable_data_frame_parsing) # success is 1, no results is -2, truncated is 2, -1 is generic error From 8cdddb5d4fd4b35c0cb3eacc68d63b89618e11e4 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Mon, 3 Jul 2023 15:40:44 -0700 Subject: [PATCH 2/3] fix: another post-API rollout bit of code --- tests/testthat/test-epidatacall.R | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/tests/testthat/test-epidatacall.R b/tests/testthat/test-epidatacall.R index 04dcc44d..fa77520c 100644 --- a/tests/testthat/test-epidatacall.R +++ b/tests/testthat/test-epidatacall.R @@ -81,21 +81,20 @@ test_that("fetch_tbl warns on non-success", { .package = "httr" ) # TODO: Turn these tests back on, when the API is fully online - # Remove on 2023-06-21 - # artificial_warning <- "* This is a warning with a leading asterisk and {braces} to make sure we don't have bulleting/glue bugs." - # debug_triplet <- readRDS(testthat::test_path("data/test-classic.rds")) %>% - # jsonlite::fromJSON() %>% - # `[[<-`("message", artificial_warning) - # local_mocked_bindings( - # # see generation code above - # fromJSON = function(...) debug_triplet, - # .package = "jsonlite" - # ) + artificial_warning <- "* This is a warning with a leading asterisk and {braces} to make sure we don't have bulleting/glue bugs." + debug_triplet <- readRDS(testthat::test_path("data/test-classic.rds")) %>% + jsonlite::fromJSON() %>% + `[[<-`("message", artificial_warning) + local_mocked_bindings( + # see generation code above + fromJSON = function(...) debug_triplet, + .package = "jsonlite" + ) - # expect_warning(epidata_call %>% fetch_tbl(), - # regexp = paste0("epidata warning: ", artificial_warning), - # fixed = TRUE - # ) + expect_warning(epidata_call %>% fetch_tbl(), + regexp = paste0("epidata warning: ", artificial_warning), + fixed = TRUE + ) }) test_that("classic only fetch", { From 2e3e50362d576f7a3556745034d621c26e20ddc3 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Mon, 3 Jul 2023 15:41:08 -0700 Subject: [PATCH 3/3] docs: not sure how endpoints was building --- vignettes/endpoints.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/endpoints.Rmd b/vignettes/endpoints.Rmd index e47b08d1..db799f87 100644 --- a/vignettes/endpoints.Rmd +++ b/vignettes/endpoints.Rmd @@ -141,7 +141,7 @@ Example call: ```{r} del <- delphi(system = "ec", epiweek = 201501) %>% fetch() -names(del[[1L]]$forecast) +names(del$forecast) ``` ### FluSurv hospitalization data