From ba306ca0855bd5574f7a262cb8aaaa860f0ceaf4 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Thu, 7 Sep 2023 11:05:08 -0700 Subject: [PATCH 1/7] fix: mac tests --- .github/workflows/R-CMD-check.yaml | 9 +++++++++ README.md | 4 ++-- tests/testthat/test-cache.R | 12 +----------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 88a4ee54..df554774 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -10,7 +10,16 @@ name: R-CMD-check jobs: R-CMD-check: + name: check ${{matrix.os}} ${{github.event_name}} runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macOS-latest + arch: + - x64 env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes diff --git a/README.md b/README.md index b9f61620..bbf3ce60 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Delphi Epidata R client [![License: MIT][mit-image]][mit-url] [![Github Actions][github-actions-image]][github-actions-url] -[![codecov](https://codecov.io/gh/dsweber2/epidatr/branch/dev/graph/badge.svg?token=jVHL9eHZNZ)](https://codecov.io/gh/dsweber2/epidatr) +[![codecov](https://codecov.io/gh/dsweber2/epidatr/branch/dev/graph/badge.svg?token=jVHL9eHZNZ)](https://app.codecov.io/gh/dsweber2/epidatr) The [Delphi Epidata API](https://cmu-delphi.github.io/delphi-epidata/) provides real-time access to epidemiological surveillance data for influenza, COVID-19, and other diseases from both official government sources such as the [Center for Disease Control (CDC)](https://www.cdc.gov/datastatistics/index.html) and [Google Trends](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/google-symptoms.html) and private partners such as [Facebook](https://delphi.cmu.edu/blog/2020/08/26/covid-19-symptom-surveys-through-facebook/) and [Change Healthcare](https://www.changehealthcare.com/). It is built and maintained by the Carnegie Mellon University [Delphi research group](https://delphi.cmu.edu/). @@ -82,7 +82,7 @@ Note that for the time being, the private endpoints (i.e. those prefixed with `pvt`) will require a separate key that needs to be passed as an argument. [mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg -[mit-url]: https://opensource.org/licenses/MIT +[mit-url]: https://opensource.org/licenses/mit [github-actions-image]: https://github.com/cmu-delphi/epidatr/workflows/ci/badge.svg [github-actions-url]: https://github.com/cmu-delphi/epidatr/actions diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index 522f97fb..d685e639 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -2,17 +2,7 @@ test_that("basic cache setup", { expect_true(is.null(cache_environ$epidatr_cache)) }) -tmp_base_dir <- Sys.getenv("TMPDIR") -new_temp_dir <- NULL -if (tmp_base_dir == "") { - new_temp_dir <- md5(paste(Sys.time(), "I am the very model of a modern major general")) -} else { - new_temp_dir <- file.path( - Sys.getenv("TMPDIR"), - md5(paste(Sys.time(), "I am the very model of a modern major general")) - ) -} - +new_temp_dir <- tempdir() test_set_cache <- function(cache_dir = new_temp_dir, days = 1, max_size = 1, From a5ed445dc2ca857588fe81179e93edcc74786313 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Thu, 7 Sep 2023 11:17:20 -0700 Subject: [PATCH 2/7] ci: more OS and r versions --- .github/workflows/R-CMD-check-full.yaml | 61 +++++++++++++++++++++++++ .github/workflows/R-CMD-check.yaml | 22 ++++++++- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/R-CMD-check-full.yaml diff --git a/.github/workflows/R-CMD-check-full.yaml b/.github/workflows/R-CMD-check-full.yaml new file mode 100644 index 00000000..f2b5fc3d --- /dev/null +++ b/.github/workflows/R-CMD-check-full.yaml @@ -0,0 +1,61 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +# +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. +on: + workflow_dispatch: + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - { os: macos-latest, r: "release" } + + - { os: windows-latest, r: "release" } + # Use 3.6 to trigger usage of RTools35 + - { os: windows-latest, r: "3.6" } + # use 4.1 to check with rtools40's older compiler + - { os: windows-latest, r: "4.1" } + + - { os: ubuntu-latest, r: "devel", http-user-agent: "release" } + - { os: ubuntu-latest, r: "release" } + - { os: ubuntu-latest, r: "oldrel-1" } + - { os: ubuntu-latest, r: "oldrel-2" } + - { os: ubuntu-latest, r: "oldrel-3" } + - { os: ubuntu-latest, r: "oldrel-4" } + # The oldest version of R we claim to support + - { os: ubuntu-latest, r: "3.5" } + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 88a4ee54..9a9a9043 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -10,15 +10,33 @@ name: R-CMD-check jobs: R-CMD-check: - runs-on: ubuntu-latest + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - { os: macos-latest, r: "release" } + - { os: windows-latest, r: "release" } + - { os: ubuntu-latest, r: "devel", http-user-agent: "release" } + - { os: ubuntu-latest, r: "release" } + - { os: ubuntu-latest, r: "oldrel-1" } + env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes + steps: - uses: actions/checkout@v3 + - uses: r-lib/actions/setup-pandoc@v2 + - uses: r-lib/actions/setup-r@v2 with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 @@ -27,3 +45,5 @@ jobs: needs: check - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true From 1d42e5b77f45d5e8ecf12bbe29ba22c1635f90c1 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Thu, 7 Sep 2023 11:43:11 -0700 Subject: [PATCH 3/7] tests: normalizePath necessary after `file.path` --- tests/testthat/test-cache.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index d685e639..5ac9d57e 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -21,11 +21,11 @@ test_that("cache set as expected", { test_set_cache() if (grepl("/", as.character(new_temp_dir))) { # this is what check produces - expect_equal(cache_info()$dir, as.character(new_temp_dir)) + expect_equal(cache_info()$dir, normalizePath(new_temp_dir)) } else { # this is what test produces directly tmp <- strsplit(cache_info()$dir, "/")[[1]] - expect_equal(tmp[length(tmp)], as.character(new_temp_dir)) + expect_equal(tmp[length(tmp)], normalizePath(new_temp_dir)) } expect_equal(cache_info()$max_size, 1024^2) expect_equal(cache_info()$max_age, 24 * 60 * 60) From fa2032694af0a61e6c1ac53cc0feceb732dc71e8 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Thu, 7 Sep 2023 15:37:02 -0700 Subject: [PATCH 4/7] fix: #169, cli_warn printing poorly --- R/cache.R | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/R/cache.R b/R/cache.R index ccc41aa2..5168cbda 100644 --- a/R/cache.R +++ b/R/cache.R @@ -250,12 +250,15 @@ cache_epidata_call <- function(epidata_call, fetch_args = fetch_args_list()) { as_of_recent <- check_is_recent(epidata_call$params$as_of, 7) issues_recent <- check_is_recent(epidata_call$params$issues, 7) if (as_of_recent || issues_recent) { - cli::cli_warn("using cached results with `as_of` within the past week (or the future!). This will likely result ", - "in an invalid cache. Consider\n", - "1. disabling the cache for this session with `disable_cache` or permanently with environmental ", - "variable `EPIDATR_USE_CACHE=FALSE`\n", - "2. setting `EPIDATR_CACHE_MAX_AGE_DAYS={Sys.getenv('EPIDATR_CACHE_MAX_AGE_DAYS', unset = 1)}` to e.g. `3/24` ", - "(3 hours).", + cli::cli_warn( + c( + "using cached results with `as_of` within the past week (or the future!).", + "This will likely result in an invalid cache. Consider\n", + "1. disabling the cache for this session with `disable_cache` or permanently with environmental ", + "variable `EPIDATR_USE_CACHE=FALSE`\n", + "2. setting `EPIDATR_CACHE_MAX_AGE_DAYS={Sys.getenv('EPIDATR_CACHE_MAX_AGE_DAYS', unset = 1)}`", + " to e.g. `3/24` (3 hours)." + ), .frequency = "regularly", .frequency_id = "cache timing issues", class = "cache_recent_data" From 3a5c02d45a54159d09b6758ef5ab8509f138f3b9 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Thu, 7 Sep 2023 16:08:31 -0700 Subject: [PATCH 5/7] docs: moved website --- DEVELOPMENT.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index df198774..95a93c25 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -27,6 +27,6 @@ The release consists of multiple steps which can be all done via the GitHub webs 5. Release to CRAN [mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg -[mit-url]: https://opensource.org/licenses/MIT +[mit-url]: https://opensource.org/license/MIT [github-actions-image]: https://github.com/cmu-delphi/epidatr/workflows/ci/badge.svg [github-actions-url]: https://github.com/cmu-delphi/epidatr/actions diff --git a/README.md b/README.md index bbf3ce60..a1d727b9 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Note that for the time being, the private endpoints (i.e. those prefixed with `pvt`) will require a separate key that needs to be passed as an argument. [mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg -[mit-url]: https://opensource.org/licenses/mit +[mit-url]: https://opensource.org/license/mit [github-actions-image]: https://github.com/cmu-delphi/epidatr/workflows/ci/badge.svg [github-actions-url]: https://github.com/cmu-delphi/epidatr/actions From 37f23a4b830fe36fdefc9be145eaea02c245736c Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Thu, 7 Sep 2023 16:45:56 -0700 Subject: [PATCH 6/7] docs: attempt to correct wiki docs --- R/endpoints.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/endpoints.R b/R/endpoints.R index 9fda143f..06b96ad6 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -1719,6 +1719,13 @@ pvt_twitter <- function(auth, locations, ..., dates = NULL, epiweeks = NULL, fet #' url <- "https://raw.githubusercontent.com/cmu-delphi/delphi-epidata/dev/docs/api/covidcast_signals.md" #' txt <- readLines(url) #' txt <- txt[7:length(txt)] +#' txt %<>% gsub("covidcast_meta", "pub_covidcast_meta", .) %>% +#' gsub("\\[`(fb-.*)`\\].*\\.md)", "\\1", .) %>% +#' gsub("\\[`(jhu-.*)`\\].*\\.md)", "\\1", .) %>% +#' gsub("\\[`(hhs.*)`\\].*\\.md)", "\\1", .) %>% +#' gsub("\\[`(goog.*)`\\].*\\.md)", "\\1", .) %>% +#' gsub("\\[`(doc.*)`\\].*\\.md)", "\\1", .) %>% +#' gsub("covidcast_changelog.md", "https://cmu-delphi.github.io/delphi-epidata/api/covidcast_changelog.html", .) #' cat(txt, sep = "\n") #' ``` #' From b0de49002580c5aa5f2efc7f23fa995b5a92561d Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Thu, 7 Sep 2023 16:46:35 -0700 Subject: [PATCH 7/7] docs: conclusion: those docs unrecoverable --- R/endpoints.R | 14 -------------- man/pub_wiki.Rd | 40 ---------------------------------------- 2 files changed, 54 deletions(-) diff --git a/R/endpoints.R b/R/endpoints.R index 06b96ad6..b95c3870 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -1715,20 +1715,6 @@ pvt_twitter <- function(auth, locations, ..., dates = NULL, epiweeks = NULL, fet #' @description #' API docs: #' -#' ```{r results="asis", echo = FALSE} -#' url <- "https://raw.githubusercontent.com/cmu-delphi/delphi-epidata/dev/docs/api/covidcast_signals.md" -#' txt <- readLines(url) -#' txt <- txt[7:length(txt)] -#' txt %<>% gsub("covidcast_meta", "pub_covidcast_meta", .) %>% -#' gsub("\\[`(fb-.*)`\\].*\\.md)", "\\1", .) %>% -#' gsub("\\[`(jhu-.*)`\\].*\\.md)", "\\1", .) %>% -#' gsub("\\[`(hhs.*)`\\].*\\.md)", "\\1", .) %>% -#' gsub("\\[`(goog.*)`\\].*\\.md)", "\\1", .) %>% -#' gsub("\\[`(doc.*)`\\].*\\.md)", "\\1", .) %>% -#' gsub("covidcast_changelog.md", "https://cmu-delphi.github.io/delphi-epidata/api/covidcast_changelog.html", .) -#' cat(txt, sep = "\n") -#' ``` -#' #' @examples #' \dontrun{ #' pub_wiki(articles = "avian_influenza", epiweeks = epirange(201501, 201601)) diff --git a/man/pub_wiki.Rd b/man/pub_wiki.Rd index d075e047..ce925ce9 100644 --- a/man/pub_wiki.Rd +++ b/man/pub_wiki.Rd @@ -36,46 +36,6 @@ pub_wiki( \description{ API docs: \url{https://cmu-delphi.github.io/delphi-epidata/api/wiki.html} } -\section{Delphi's COVID-19 Data Sources and Signals}{ -Delphi's COVID-19 Surveillance Streams data includes the following data sources. -Data from most of these sources is typically updated daily. You can use the -\href{covidcast_meta.md}{\code{covidcast_meta}} endpoint to get summary information -about the ranges of the different attributes for the different data sources. - -The API for retrieving data from these sources is described in the -\href{covidcast.md}{COVIDcast endpoint documentation}. Changes and corrections to -data from this endpoint are listed in the \href{covidcast_changelog.md}{changelog}. - -To obtain many of these signals and update them daily, Delphi has written -extensive software to obtain data from various sources, aggregate the data, -calculate statistical estimates, and format the data to be shared through the -COVIDcast endpoint of the Delphi Epidata API. This code is -\href{https://github.com/cmu-delphi/covidcast-indicators}{open source and available on GitHub}, -and contributions are welcome. -\subsection{COVIDcast Dashboard Signals}{ - -The following signals are currently displayed on \href{https://delphi.cmu.edu/covidcast/}{the public COVIDcast dashboard}:\tabular{llll}{ - Kind \tab Name \tab Source \tab Signal \cr - Public Behavior \tab People Wearing Masks \tab \href{covidcast-signals/fb-survey.md}{\code{fb-survey}} \tab \code{smoothed_wwearing_mask_7d} \cr - Public Behavior \tab Vaccine Acceptance \tab \href{covidcast-signals/fb-survey.md}{\code{fb-survey}} \tab \code{smoothed_wcovid_vaccinated_appointment_or_accept} \cr - Public Behavior \tab COVID Symptom Searches on Google \tab \href{covidcast-signals/google-symptoms.md}{\code{google-symptoms}} \tab \code{sum_anosmia_ageusia_smoothed_search} \cr - Early Indicators \tab COVID-Like Symptoms \tab \href{covidcast-signals/fb-survey.md}{\code{fb-survey}} \tab \code{smoothed_wcli} \cr - Early Indicators \tab COVID-Like Symptoms in Community \tab \href{covidcast-signals/fb-survey.md}{\code{fb-survey}} \tab \code{smoothed_whh_cmnty_cli} \cr - Early Indicators \tab COVID-Related Doctor Visits \tab \href{covidcast-signals/doctor-visits.md}{\code{doctor-visits}} \tab \code{smoothed_adj_cli} \cr - Cases and Testing \tab COVID Cases \tab \href{covidcast-signals/jhu-csse.md}{\code{jhu-csse}} \tab \code{confirmed_7dav_incidence_prop} \cr - Late Indicators \tab COVID Hospital Admissions \tab \href{covidcast-signals/hhs.md}{\code{hhs}} \tab \code{confirmed_admissions_covid_1d_prop_7dav} \cr - Late Indicators \tab Deaths \tab \href{covidcast-signals/jhu-csse.md}{\code{jhu-csse}} \tab \code{deaths_7dav_incidence_prop} \cr -} - -} - -\subsection{All Available Sources and Signals}{ - -Beyond the signals available on the COVIDcast dashboard, numerous other signals are -available through our \href{https://delphi.cmu.edu/covidcast/export/}{data export tool} or directly through the API: -} -} - \examples{ \dontrun{ pub_wiki(articles = "avian_influenza", epiweeks = epirange(201501, 201601))