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

1.2.0 release #282

Merged
merged 25 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4f4c14c
change expected timecol output type based on `time_type`
nmdefries Feb 29, 2024
0424f6b
style: styler (GHA)
nmdefries Feb 29, 2024
0209e95
error if nchs requested not weekly
nmdefries Mar 1, 2024
327d7fc
version and news
nmdefries Mar 1, 2024
dac2bc3
don't check missingness on args with defaults -- covidcast
nmdefries Mar 4, 2024
23b4729
test
nmdefries Mar 4, 2024
3a21d59
version and news
nmdefries Mar 4, 2024
fe42abc
Merge pull request #260 from cmu-delphi/ndefries/nchs-week-parsing
nmdefries Mar 4, 2024
5d63158
Merge branch 'dev' into ndefries/less-sensitive-missing-checks
nmdefries Mar 4, 2024
a468211
don't check missingness on args with defaults -- covid_hosp_state
nmdefries Mar 4, 2024
263cdf8
Merge pull request #267 from cmu-delphi/main
dshemetov Mar 4, 2024
563ff9f
document wildcard default
nmdefries Mar 4, 2024
c33d7c2
Merge pull request #268 from cmu-delphi/ndefries/less-sensitive-missi…
nmdefries Mar 5, 2024
28a49cd
fix: improve reading of EPIDATR_USE_CACHE variable
dshemetov Mar 7, 2024
a6265f1
doc: bump version and add NEWS line
dshemetov Mar 7, 2024
4e97718
doc: credit Nat as contributor
dshemetov Mar 7, 2024
1ae608d
Merge pull request #274 from cmu-delphi/ds/nat
dshemetov Mar 7, 2024
6b98373
Merge pull request #273 from cmu-delphi/ds/cache-fix
dshemetov Mar 8, 2024
1f4d894
pkgdown fixes, DEVELOPMENT release notes
dsweber2 Mar 13, 2024
a53ad56
Merge pull request #275 from cmu-delphi/formatMergeback
dsweber2 Mar 20, 2024
c51f982
support YYYY-MM-DD format in date_to_epiweek
nmdefries Mar 27, 2024
96157f9
version
nmdefries Mar 27, 2024
626c30b
Merge pull request #276 from cmu-delphi/ndefries/date_to_epiweek-gene…
nmdefries Mar 27, 2024
3bad057
minor test fixes, NEWS, dev link borked, version bump
dsweber2 Jun 19, 2024
e99f4b6
Merge pull request #281 from cmu-delphi/1.2release
dsweber2 Jun 20, 2024
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
25 changes: 14 additions & 11 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ name: pkgdown

jobs:
pkgdown:
# only build docs on the main repository and not forks
if: github.repository_owner == 'cmu-delphi'
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
Expand All @@ -39,19 +40,21 @@ jobs:
needs: website

- name: Build site
# - target_ref gets the ref from a different variable, depending on the event
# - override allows us to set the pkgdown mode and version_label
# - mode: release is the standard build mode, devel places the site in /dev
# - version_label: 'light' and 'success' are CSS labels for Bootswatch: Cosmo
# https://bootswatch.com/cosmo/
# - we use pkgdown:::build_github_pages to build the site because of an issue in pkgdown
# https://github.com/r-lib/pkgdown/issues/2257
run: |
override <- if (startsWith("${{ github.event_name }}", "pull_request")) {
if ("${{ github.base_ref }}" == "main") {
list(development = list(mode = "release", version_label = "light"))
} else {
list(development = list(mode = "devel", version_label = "success"))
}
target_ref <- "${{ github.event_name == 'pull_request' && github.base_ref || github.ref }}"
override <- if (target_ref == "main" || target_ref == "refs/heads/main") {
list(development = list(mode = "release", version_label = "light"))
} else if (target_ref == "dev" || target_ref == "refs/heads/dev") {
list(development = list(mode = "devel", version_label = "success"))
} else {
if ("${{ github.ref_name }}" == "main") {
list(development = list(mode = "release", version_label = "light"))
} else {
list(development = list(mode = "devel", version_label = "success"))
}
stop("Unexpected target_ref: ", target_ref)
}
pkg <- pkgdown::as_pkgdown(".", override = override)
cli::cli_rule("Cleaning files from old site...")
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Package: epidatr
Type: Package
Title: Client for Delphi's 'Epidata' API
Version: 1.1.1
Version: 1.2.0
Authors@R:
c(
person("Logan", "Brooks", email = "[email protected]", role = c("aut")),
person("Dmitry", "Shemetov", email = "[email protected]", role = c("aut")),
person("Samuel", "Gratzl", email = "[email protected]", role = c("aut")),
person("David", "Weber", email = "[email protected]", role = c("ctb", "cre")),
person("Nat", "DeFries", role = c("ctb")),
person("Alex", "Reinhart", role = c("ctb")),
person("Daniel", "McDonald", role = c("ctb")),
person("Kean Ming", "Tan", role = c("ctb")),
Expand Down
24 changes: 14 additions & 10 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ Please follow the guidelines in the [PR template document](.github/pull_request_

Open a release issue and then copy and follow this checklist in the issue (modified from the checklist generated by `usethis::use_release_issue(version = "1.0.2")`):

- [ ] `git pull`
- [ ] Check [current CRAN check results](https://cran.rstudio.org/web/checks/check_results_epidatr.html)

Open a release issue and then copy and follow this checklist in the issue (modified from the checklist generated by `usethis::use_release_issue(version = "1.0.2")`):

- [ ] `git pull` on `dev` branch.
- [ ] Make sure all changes are committed and pushed.
- [ ] Check [current CRAN check results](https://cran.rstudio.org/web/checks/check_results_epidatr.html).
- [ ] `devtools::check(".", manual = TRUE, env_vars = c(NOT_CRAN = "false"))`.
- Aim for 10/10, no notes.
- [ ] If check works well enough, merge to main. Otherwise open a PR to fix up.
Expand All @@ -61,20 +65,20 @@ Open a release issue and then copy and follow this checklist in the issue (modif
- This may choke on the MIT license url, and that's ok.
- [ ] `devtools::build_readme()`
- [ ] `devtools::check_win_devel()`
- [ ] Check email for problems
- [ ] Have maintainer ("cre" in description) check email for problems.
- [ ] `revdepcheck::revdep_check(num_workers = 4)`.
- This may choke, it is very sensitive to the binary versions of packages on a given system. Either bypass or ask someone else to run it if you're concerned.
- [ ] Update `cran-comments.md`
- [ ] PR with any changes
- [ ] PR with any changes (and go through the list again) into `dev` and run through the list again.

Submit to CRAN:

- [ ] `devtools::submit_cran()`
- [ ] Approve email
- [ ] `devtools::submit_cran()`.
- [ ] Maintainer approves email.

Wait for CRAN...

- [ ] Accepted :tada:
- [ ] `dev`
- [ ] `usethis::use_github_release(publish = FALSE)` (publish off, otherwise it won't push).
- [ ] check the release notes and publish the branch on github
- [ ] If accepted :tada:, move to next steps. If rejected, fix and resubmit.
- [ ] Open and merge a PR containing any updates made to `main` back to `dev`.
- [ ] `usethis::use_github_release(publish = FALSE)` (publish off, otherwise it won't push) will create a draft release based on the commit hash in CRAN-SUBMISSION and push a tag to the GitHub repo.
- [ ] Go to the repo, verify the release notes, and publish when ready.
25 changes: 23 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,52 @@
# epidatr 1.2.0

## Changes

- Improve handling of the `EPIDATR_USE_CACHE` environment variable, allowing it
to be any value convertable by `as.logical()` and handle the case when it
can't be converted.
- Support more date formats in function to convert dates to epiweeks. Use `parse_api_date` since it already supports both common formats. #276
- `EPIDATR_USE_CACHE` only supported exactly "TRUE" before. Now it supports all logical values and includes a warning when any value that can't be converted to logical is provided. #273
- `missing` doesn't count default values as non-missing. If a user doesn't pass `geo_values` or `time_values` (both of which default to `"*"` in `pub_covidcast`), or `dates` (in `pub_covid_hosp_state_timeseries`), the missing check fails. To avoid this, just don't check missingness of those two arguments.

# epidatr 1.1.1

## Changes

## Features

## Patches
- Fixed failure when passing `as_of` values in `Date` format to
`pub_covidcast` while caching is enabled (#259)

- Fix failure when passing `as_of` values in `Date` format to
`pub_covidcast` while caching is enabled (#259).
- For `pub_covidcast` data source `nchs-mortality`, parse dates as `epiweek`
and expect `epiweek` inputs from user (#260).
- Fix failure in `pub_covidcast` when user doesn't pass `geo_values` or
`time_values`, even though those arguments have defaults (#268).

# 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 correctly parses the `issue` field,
Expand Down
44 changes: 30 additions & 14 deletions R/endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,10 @@ pub_covid_hosp_state_timeseries <- function(
# Check parameters
rlang::check_dots_empty()

if (missing(states) || missing(dates)) {
stop(
"`states` and `dates` are both required"
if (missing(states)) {
cli::cli_abort(
"`states` is required",
class = "epidatr__pub_covid_hosp_state_timeseries__missing_required_args"
)
}

Expand Down Expand Up @@ -960,9 +961,9 @@ pub_covidcast_meta <- function(fetch_args = fetch_args_list()) {
#' <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html>).
#' @param time_type string. The temporal resolution of the data (either "day" or
#' "week", depending on signal).
#' @param geo_values character. The geographies to return. "*" fetches
#' all. (See:
#' <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html>.)
#' @param geo_values character. The geographies to return. Defaults to all
#' ("*") geographies within requested geographic resolution (see:
#' <https://cmu-delphi.github.io/delphi-epidata/api/covidcast_geography.html>.).
#' @param time_values [`timeset`]. Dates to fetch. Defaults to all ("*") dates.
#' @param ... not used for values, forces later arguments to bind by name
#' @param as_of Date. Optionally, the as of date for the issues to fetch. If not
Expand Down Expand Up @@ -999,17 +1000,19 @@ pub_covidcast <- function(
missing(source) ||
missing(signals) ||
missing(time_type) ||
missing(geo_type) ||
missing(time_values) ||
missing(geo_values)
missing(geo_type)
) {
stop(
"`source`, `signals`, `time_type`, `geo_type`, `time_values`, and `geo_values` are all required"
cli::cli_abort(
"`source`, `signals`, `time_type`, and `geo_type` are all required",
class = "epidatr__pub_covidcast__missing_required_args"
)
}

if (sum(!is.null(issues), !is.null(lag), !is.null(as_of)) > 1) {
stop("`issues`, `lag`, and `as_of` are mutually exclusive")
cli::cli_abort(
"`issues`, `lag`, and `as_of` are mutually exclusive",
class = "epidatr__pub_covidcast__too_many_issue_params"
)
}

assert_character_param("data_source", source, len = 1)
Expand All @@ -1025,6 +1028,13 @@ pub_covidcast <- function(
as_of <- parse_timeset_input(as_of)
issues <- parse_timeset_input(issues)

if (source == "nchs-mortality" && time_type != "week") {
cli::cli_abort(
"{source} data is only available at the week level",
class = "epidatr__nchs_week_only"
)
}

create_epidata_call(
"covidcast/",
list(
Expand All @@ -1051,8 +1061,14 @@ pub_covidcast <- function(
c("day", "week")
),
create_epidata_field_info("geo_value", "text"),
create_epidata_field_info("time_value", "date"),
create_epidata_field_info("issue", "date"),
create_epidata_field_info("time_value", switch(time_type,
day = "date",
week = "epiweek"
)),
create_epidata_field_info("issue", switch(time_type,
day = "date",
week = "epiweek"
)),
create_epidata_field_info("lag", "int"),
create_epidata_field_info("value", "float"),
create_epidata_field_info("stderr", "float"),
Expand Down
10 changes: 8 additions & 2 deletions R/epidatr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
"_PACKAGE"

.onLoad <- function(libname, pkgname) {
cache_environ$use_cache <- Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE)
cache_environ$use_cache <- (cache_environ$use_cache == "TRUE")
cache_environ$use_cache <- as.logical(Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE))
if (is.na(cache_environ$use_cache)) {
cli::cli_warn(
"Failed to read EPIDATR_USE_CACHE environment variable.
Should be a logical. Defaulting to FALSE."
)
cache_environ$use_cache <- FALSE
}
if (cache_environ$use_cache) {
set_cache(startup = TRUE)
}
Expand Down
2 changes: 1 addition & 1 deletion R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ parse_data_frame <- function(epidata_call, df, disable_date_parsing = FALSE) {
#' @importFrom MMWRweek MMWRweek
#' @keywords internal
date_to_epiweek <- function(value) {
date_components <- MMWRweek::MMWRweek(as.Date(as.character(value), "%Y%m%d"))
date_components <- MMWRweek::MMWRweek(parse_api_date(value))
as.numeric(paste0(
date_components$MMWRyear,
# Pad with zeroes up to 2 digits (x -> 0x)
Expand Down
10 changes: 7 additions & 3 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Colors should stay consistent across epipredict & epidatr, using Carnegie
# Red https://www.cmu.edu/brand/brand-guidelines/visual-identity/colors.html
# Colors should stay consistent across epipredict, epiprocess, and epidatr,
# using Carnegie Red
# https://www.cmu.edu/brand/brand-guidelines/visual-identity/colors.html

# This is to give a default value to the `mode` parameter in the
# `pkgdown::build_site` function. This is useful when building the site locally,
Expand All @@ -15,11 +16,14 @@ template:
bslib:
font_scale: 1.0
primary: "#C41230"
success: "#B4D43C"
link-color: "#C41230"

navbar:
bg: primary
type: dark
type: light

url: https://cmu-delphi.github.io/epidatr/

home:
links:
Expand Down
1 change: 1 addition & 0 deletions man/epidatr-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/pub_covidcast.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions tests/testthat/test-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test_set_cache <- function(cache_dir = new_temp_dir,
}

test_that("cache set as expected", {
test_set_cache()
expect_message(test_set_cache())
if (grepl("/", as.character(new_temp_dir))) {
# this is what check produces
expect_equal(cache_info()$dir, normalizePath(new_temp_dir))
Expand All @@ -38,7 +38,7 @@ test_that("cache set as expected", {

# use an existing example to save, then load and compare the values
test_that("cache saves & loads", {
test_set_cache()
expect_message(test_set_cache())
epidata_call <- pub_covidcast(
source = "jhu-csse",
signals = "confirmed_7dav_incidence_prop",
Expand Down Expand Up @@ -128,7 +128,7 @@ test_that("check_is_cachable", {
expect_false(check_is_cachable(epidata_call, fetch_args))
}
}
test_set_cache()
expect_message(test_set_cache())
check_fun(expected_result = FALSE) # doesn't specify issues or as_of
check_fun(as_of = "2020-01-01", expected_result = TRUE) # valid as_of
check_fun(issues = "2020-01-01", expected_result = TRUE) # valid issues
Expand Down Expand Up @@ -178,14 +178,14 @@ test_that("check_is_cachable", {
# cases where the cache isn't active
disable_cache()
check_fun(as_of = "2020-01-01", expected_result = FALSE)
test_set_cache()
expect_message(test_set_cache())
cache_environ$epidatr_cache <- NULL
check_fun(as_of = "2020-01-01", expected_result = FALSE)
test_set_cache()
expect_message(test_set_cache())
check_fun(as_of = "2020-01-01", expected_result = TRUE)
})

test_set_cache()
expect_message(test_set_cache())
cache_environ$epidatr_cache$prune()
clear_cache(disable = TRUE)
rm(new_temp_dir)
Expand Down
Loading
Loading