diff --git a/.Rbuildignore b/.Rbuildignore index 9815dfff..697d8b52 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -23,3 +23,4 @@ ^README\.Rmd$ ^CRAN-SUBMISSION$ ^LICENSE\.md$ +^revdep$ diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 14a572e7..ee44a838 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -4,8 +4,8 @@ Please: - [ ] Make sure this PR is against "dev", not "main" (unless this is a release PR). -- [ ] Request a review from one of the current epiprocess main reviewers: - brookslogan, nmdefries. +- [ ] Request a review from one of the current epidatr main reviewers: + brookslogan, dshemetov, nmdefries, dsweber2. - [ ] Makes sure to bump the version number in `DESCRIPTION`. Always increment the patch version number (the third number), unless you are making a release PR from dev to main, in which case increment the minor version diff --git a/DESCRIPTION b/DESCRIPTION index 6d678434..89fe1ad4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,7 @@ Package: epidatr Type: Package Title: Client for Delphi's 'Epidata' API -Version: 1.0.2 -Date: 2023-12-07 +Version: 1.1.0 Authors@R: c( person("Logan", "Brooks", email = "lcbrooks@andrew.cmu.edu", role = c("aut")), diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index e8223c9c..63e3340f 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -45,5 +45,20 @@ python -m http.server -d docs Please follow the guidelines in the [PR template document](.github/pull_request_template.md). ## Release process +First, there's a handy function that makes a github issue; for example, at the time of writing we were doing: +```R +usethis::use_release_issue(version = "1.0.2") +``` +If you want to extend it, add to the `release_bullets` function in [utils.R](https://github.com/cmu-delphi/epidatr/blob/dev/R/utils.R). + First, make sure that all the checks pass + +```R +devtools::check(".", manual = TRUE, env_vars =c(NOT_CRAN = "false")) +``` -TBD +Aim for 10/10, no notes. Generally, follow the issue. `revdep_check` is likely to fail but doesn't seem to be terribly important. So for now ignore it. + +When this has gone smoothly enough, release to CRAN via +```R +devtools::release(check = TRUE) +``` diff --git a/NAMESPACE b/NAMESPACE index d0907cfd..c6fed522 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -81,6 +81,7 @@ importFrom(openssl,md5) importFrom(purrr,map_chr) importFrom(purrr,map_lgl) importFrom(readr,read_csv) +importFrom(stats,na.omit) importFrom(tibble,as_tibble) importFrom(tibble,tibble) importFrom(utils,help.search) diff --git a/NEWS.md b/NEWS.md index 41ef133d..10626ad3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,29 +1,32 @@ # epidatr 1.1.0 +## Changes +- `pub_covid_hosp_state_timeseries` now supports use of the `as_of` parameter (#209). +- `release_date` and `latest_update` fields are now parsed as `Date`, rather + than as text. This change impacts several endpoints. +- `get_auth_key` renamed to `get_api_key` (#181). +- `get_api_key` no longer reads from R options and only uses environment variables (#217). +- `pvt_twitter` and `pub_wiki` now use `time_type` and `time_values` args instead of mutually exclusive `dates` and `epiweeks` (#236). This matches the interface of the `pub_covidcast` endpoint. +- Updated the default `timeout_seconds` to 15 minutes to allow large queries by default. +## Features - Function reference now displays commonly-used functions first (#205). +- Support `Date` objects passed to version arguments `as_of` and `issues` in + endpoints (#192, #194). +- `clear_cache` now handles positional arguments just like `set_cache` (#197). +- `set_api_key` now available to help persist API key environment variables (#181, #217). +- All endpoints now support the use of "\*" as a wildcard to fetch all dates or epiweeks (#234). +## Patches - Endpoints now fail when passed misspelled arguments (#187, #201). - `pub_fluview_meta` fixed to `fetch` the response automatically. -- `pub_covid_hosp_state_timeseries` now supports use of the `as_of` parameter (#209). - `pub_covid_hosp_state_timeseries` now correctly parses the `issue` field, instead of returning a missing value (#202). -- `release_date` and `latest_update` fields are now parsed as `Date`, rather - than as text. This change impacts several endpoints.. - In `pub_fluview_meta`, `latest_issue` field is now parsed as epiweek, rather than being parsed as `Date` and returning a missing value. -- Support `Date` objects passed to version arguments `as_of` and `issues` in - endpoints (#192, #194). - `set_cache` cache size no longer runs into integer overflow (#189). -- `clear_cache` now handles positional arguments just like `set_cache` (#197). - Improve line-wrapping of warning messages (#191). -- `set_api_key` now available to help persist API key environment variables (#181, #217). -- `get_auth_key` renamed to `get_api_key` (#181). -- `get_api_key` no longer reads from R options and only uses environment variables (#217). - Fix documentation related to CRAN submission. - Fix some errors from passing "" as a key. -- `pvt_twitter` and `pub_wiki` now use `time_type` and `time_values` args instead of mutually exclusive `dates` and `epiweeks` (#236). This matches the interface of the `pub_covidcast` endpoint. -- All endpoints now support the use of "\*" as a wildcard to fetch all dates or epiweeks (#234). - Fixed bug with NAs when parsing ints (#243). -- Updated the default `timeout_seconds` to 15 minutes to allow large queries by default. # epidatr 1.0.0 diff --git a/R/cache.R b/R/cache.R index 75c9473f..bc30b48f 100644 --- a/R/cache.R +++ b/R/cache.R @@ -90,6 +90,8 @@ cache_environ$epidatr_cache <- NULL #' variable is `EPIDATR_CACHE_LOGFILE`. #' @param confirm whether to confirm directory creation. default is `TRUE`; #' should only be set in non-interactive scripts +#' @param startup indicates whether the function is being called on +#' startup. Affects suppressability of the messages. Default is `FALSE`. #' @return [`NULL`] no return value, all effects are stored in the package #' environment #' @seealso [`clear_cache`] to delete the old cache while making a new one, @@ -102,7 +104,8 @@ set_cache <- function(cache_dir = NULL, days = NULL, max_size = NULL, logfile = NULL, - confirm = TRUE) { + confirm = TRUE, + startup = FALSE) { if (is.null(cache_dir)) { cache_dir <- Sys.getenv("EPIDATR_CACHE_DIR", unset = rappdirs::user_cache_dir("R", version = "epidatr")) } else if (is.null(cache_dir)) { @@ -171,9 +174,10 @@ set_cache <- function(cache_dir = NULL, cli::cli_inform(c( "!" = "epidatr cache is being used (set env var EPIDATR_USE_CACHE=FALSE if not intended).", "i" = "The cache directory is {cache_dir}.", - "i" = "The cache will be cleared after {days} days and will be pruned if it exceeds {max_size} MB.", + "i" = "The cache will be cleared after {days} day{ifelse(days>1,'s','')} + and will be pruned if it exceeds {max_size} MB.", "i" = "The log of cache transactions is stored at {file.path(cache_dir, logfile)}." - )) + ), class = if (startup) "packageStartupMessage" else NULL) } #' Manually reset the cache, deleting all currently saved data and starting afresh diff --git a/R/epidatr-package.R b/R/epidatr-package.R index ad1ed5da..1b22c9e4 100644 --- a/R/epidatr-package.R +++ b/R/epidatr-package.R @@ -11,6 +11,6 @@ cache_environ$use_cache <- Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE) cache_environ$use_cache <- (cache_environ$use_cache == "TRUE") if (cache_environ$use_cache) { - set_cache() + set_cache(startup = TRUE) } } diff --git a/R/model.R b/R/model.R index e88b8e7a..90bddd51 100644 --- a/R/model.R +++ b/R/model.R @@ -165,6 +165,7 @@ print.EpidataFieldInfo <- function(x, ...) { cli::cli_dl(x[attr(x, "names")]) } +#' @importFrom stats na.omit parse_value <- function(info, value, disable_date_parsing = FALSE) { stopifnot(inherits(info, "EpidataFieldInfo")) diff --git a/R/utils.R b/R/utils.R index 705ff368..5fbe5cbb 100644 --- a/R/utils.R +++ b/R/utils.R @@ -61,3 +61,9 @@ get_wildcard_equivalent_dates <- function(time_value, time_type = c("day", "week } return(time_value) } + +#' inserts each string as a bullet at the end of the "Prepare for release" section +#' @keywords internal +release_bullets <- function() { + c("merge to main") +} diff --git a/README.Rmd b/README.Rmd index 8829f907..319cf4fa 100644 --- a/README.Rmd +++ b/README.Rmd @@ -112,6 +112,6 @@ See also the [Terms of Use](https://delphi.cmu.edu/covidcast/terms-of-use/), not [mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg -[mit-url]: https://opensource.org/license/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 ac2dace0..31b1305e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![License: -MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit/) +MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit) [![Github Actions](https://github.com/cmu-delphi/epidatr/workflows/ci/badge.svg)](https://github.com/cmu-delphi/epidatr/actions) [![codecov](https://codecov.io/gh/dsweber2/epidatr/branch/dev/graph/badge.svg?token=jVHL9eHZNZ)](https://app.codecov.io/gh/dsweber2/epidatr) @@ -39,6 +39,13 @@ also provide packages for downstream data processing ``` r library(epidatr) +#> ! epidatr cache is being used (set env var EPIDATR_USE_CACHE=FALSE if not +#> intended). +#> ℹ The cache directory is /fasterHome/workingDataDir/epidatr. +#> ℹ The cache will be cleared after 1 day and will be pruned if it exceeds 1024 +#> MB. +#> ℹ The log of cache transactions is stored at +#> /fasterHome/workingDataDir/epidatr/logfile.txt. # Obtain the smoothed covid-like illness (CLI) signal from Delphi's US COVID-19 # Trends and Impact Survey (CTIS), in partnership with Facebook, as it was on # April 10, 2021 for the US at the national level diff --git a/man/clear_cache.Rd b/man/clear_cache.Rd index e84740f8..f5d232b9 100644 --- a/man/clear_cache.Rd +++ b/man/clear_cache.Rd @@ -25,6 +25,8 @@ cache directory. By default, it is \code{"logfile.txt"}. The environmental variable is \code{EPIDATR_CACHE_LOGFILE}.} \item{\code{confirm}}{whether to confirm directory creation. default is \code{TRUE}; should only be set in non-interactive scripts} + \item{\code{startup}}{indicates whether the function is being called on +startup. Affects suppressability of the messages. Default is \code{FALSE}.} }} \item{disable}{instead of setting a new cache, disable caching entirely; diff --git a/man/release_bullets.Rd b/man/release_bullets.Rd new file mode 100644 index 00000000..64e1341b --- /dev/null +++ b/man/release_bullets.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{release_bullets} +\alias{release_bullets} +\title{inserts each string as a bullet at the end of the "Prepare for release" section} +\usage{ +release_bullets() +} +\description{ +inserts each string as a bullet at the end of the "Prepare for release" section +} +\keyword{internal} diff --git a/man/set_cache.Rd b/man/set_cache.Rd index 72bc0847..6787edf0 100644 --- a/man/set_cache.Rd +++ b/man/set_cache.Rd @@ -9,7 +9,8 @@ set_cache( days = NULL, max_size = NULL, logfile = NULL, - confirm = TRUE + confirm = TRUE, + startup = FALSE ) } \arguments{ @@ -32,6 +33,9 @@ variable is \code{EPIDATR_CACHE_LOGFILE}.} \item{confirm}{whether to confirm directory creation. default is \code{TRUE}; should only be set in non-interactive scripts} + +\item{startup}{indicates whether the function is being called on +startup. Affects suppressability of the messages. Default is \code{FALSE}.} } \value{ \code{\link{NULL}} no return value, all effects are stored in the package