Skip to content

Commit 91770df

Browse files
authored
Merge pull request #282 from cmu-delphi/dev
1.2.0 release
2 parents 5f35c0d + e99f4b6 commit 91770df

File tree

12 files changed

+173
-53
lines changed

12 files changed

+173
-53
lines changed

.github/workflows/pkgdown.yaml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ name: pkgdown
1616

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

4142
- name: Build site
43+
# - target_ref gets the ref from a different variable, depending on the event
44+
# - override allows us to set the pkgdown mode and version_label
45+
# - mode: release is the standard build mode, devel places the site in /dev
46+
# - version_label: 'light' and 'success' are CSS labels for Bootswatch: Cosmo
47+
# https://bootswatch.com/cosmo/
48+
# - we use pkgdown:::build_github_pages to build the site because of an issue in pkgdown
49+
# https://github.com/r-lib/pkgdown/issues/2257
4250
run: |
43-
override <- if (startsWith("${{ github.event_name }}", "pull_request")) {
44-
if ("${{ github.base_ref }}" == "main") {
45-
list(development = list(mode = "release", version_label = "light"))
46-
} else {
47-
list(development = list(mode = "devel", version_label = "success"))
48-
}
51+
target_ref <- "${{ github.event_name == 'pull_request' && github.base_ref || github.ref }}"
52+
override <- if (target_ref == "main" || target_ref == "refs/heads/main") {
53+
list(development = list(mode = "release", version_label = "light"))
54+
} else if (target_ref == "dev" || target_ref == "refs/heads/dev") {
55+
list(development = list(mode = "devel", version_label = "success"))
4956
} else {
50-
if ("${{ github.ref_name }}" == "main") {
51-
list(development = list(mode = "release", version_label = "light"))
52-
} else {
53-
list(development = list(mode = "devel", version_label = "success"))
54-
}
57+
stop("Unexpected target_ref: ", target_ref)
5558
}
5659
pkg <- pkgdown::as_pkgdown(".", override = override)
5760
cli::cli_rule("Cleaning files from old site...")

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
Package: epidatr
22
Type: Package
33
Title: Client for Delphi's 'Epidata' API
4-
Version: 1.1.1
4+
Version: 1.2.0
55
Authors@R:
66
c(
77
person("Logan", "Brooks", email = "[email protected]", role = c("aut")),
88
person("Dmitry", "Shemetov", email = "[email protected]", role = c("aut")),
99
person("Samuel", "Gratzl", email = "[email protected]", role = c("aut")),
1010
person("David", "Weber", email = "[email protected]", role = c("ctb", "cre")),
11+
person("Nat", "DeFries", role = c("ctb")),
1112
person("Alex", "Reinhart", role = c("ctb")),
1213
person("Daniel", "McDonald", role = c("ctb")),
1314
person("Kean Ming", "Tan", role = c("ctb")),

DEVELOPMENT.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ Please follow the guidelines in the [PR template document](.github/pull_request_
4848

4949
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")`):
5050

51-
- [ ] `git pull`
52-
- [ ] Check [current CRAN check results](https://cran.rstudio.org/web/checks/check_results_epidatr.html)
51+
52+
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")`):
53+
54+
- [ ] `git pull` on `dev` branch.
55+
- [ ] Make sure all changes are committed and pushed.
56+
- [ ] Check [current CRAN check results](https://cran.rstudio.org/web/checks/check_results_epidatr.html).
5357
- [ ] `devtools::check(".", manual = TRUE, env_vars = c(NOT_CRAN = "false"))`.
5458
- Aim for 10/10, no notes.
5559
- [ ] If check works well enough, merge to main. Otherwise open a PR to fix up.
@@ -61,20 +65,20 @@ Open a release issue and then copy and follow this checklist in the issue (modif
6165
- This may choke on the MIT license url, and that's ok.
6266
- [ ] `devtools::build_readme()`
6367
- [ ] `devtools::check_win_devel()`
64-
- [ ] Check email for problems
68+
- [ ] Have maintainer ("cre" in description) check email for problems.
6569
- [ ] `revdepcheck::revdep_check(num_workers = 4)`.
6670
- 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.
6771
- [ ] Update `cran-comments.md`
68-
- [ ] PR with any changes
72+
- [ ] PR with any changes (and go through the list again) into `dev` and run through the list again.
6973

7074
Submit to CRAN:
7175

72-
- [ ] `devtools::submit_cran()`
73-
- [ ] Approve email
76+
- [ ] `devtools::submit_cran()`.
77+
- [ ] Maintainer approves email.
7478

7579
Wait for CRAN...
7680

77-
- [ ] Accepted :tada:
78-
- [ ] `dev`
79-
- [ ] `usethis::use_github_release(publish = FALSE)` (publish off, otherwise it won't push).
80-
- [ ] check the release notes and publish the branch on github
81+
- [ ] If accepted :tada:, move to next steps. If rejected, fix and resubmit.
82+
- [ ] Open and merge a PR containing any updates made to `main` back to `dev`.
83+
- [ ] `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.
84+
- [ ] Go to the repo, verify the release notes, and publish when ready.

NEWS.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,52 @@
1+
# epidatr 1.2.0
2+
3+
## Changes
4+
5+
- Improve handling of the `EPIDATR_USE_CACHE` environment variable, allowing it
6+
to be any value convertable by `as.logical()` and handle the case when it
7+
can't be converted.
8+
- Support more date formats in function to convert dates to epiweeks. Use `parse_api_date` since it already supports both common formats. #276
9+
- `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
10+
- `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.
11+
112
# epidatr 1.1.1
213

314
## Changes
415

516
## Features
617

718
## Patches
8-
- Fixed failure when passing `as_of` values in `Date` format to
9-
`pub_covidcast` while caching is enabled (#259)
19+
20+
- Fix failure when passing `as_of` values in `Date` format to
21+
`pub_covidcast` while caching is enabled (#259).
22+
- For `pub_covidcast` data source `nchs-mortality`, parse dates as `epiweek`
23+
and expect `epiweek` inputs from user (#260).
24+
- Fix failure in `pub_covidcast` when user doesn't pass `geo_values` or
25+
`time_values`, even though those arguments have defaults (#268).
1026

1127
# epidatr 1.1.0
1228

1329
## Changes
30+
1431
- `pub_covid_hosp_state_timeseries` now supports use of the `as_of` parameter (#209).
1532
- `release_date` and `latest_update` fields are now parsed as `Date`, rather
1633
than as text. This change impacts several endpoints.
1734
- `get_auth_key` renamed to `get_api_key` (#181).
1835
- `get_api_key` no longer reads from R options and only uses environment variables (#217).
1936
- `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.
2037
- Updated the default `timeout_seconds` to 15 minutes to allow large queries by default.
38+
2139
## Features
40+
2241
- Function reference now displays commonly-used functions first (#205).
2342
- Support `Date` objects passed to version arguments `as_of` and `issues` in
2443
endpoints (#192, #194).
2544
- `clear_cache` now handles positional arguments just like `set_cache` (#197).
2645
- `set_api_key` now available to help persist API key environment variables (#181, #217).
2746
- All endpoints now support the use of "\*" as a wildcard to fetch all dates or epiweeks (#234).
47+
2848
## Patches
49+
2950
- Endpoints now fail when passed misspelled arguments (#187, #201).
3051
- `pub_fluview_meta` fixed to `fetch` the response automatically.
3152
- `pub_covid_hosp_state_timeseries` now correctly parses the `issue` field,

R/endpoints.R

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,10 @@ pub_covid_hosp_state_timeseries <- function(
576576
# Check parameters
577577
rlang::check_dots_empty()
578578

579-
if (missing(states) || missing(dates)) {
580-
stop(
581-
"`states` and `dates` are both required"
579+
if (missing(states)) {
580+
cli::cli_abort(
581+
"`states` is required",
582+
class = "epidatr__pub_covid_hosp_state_timeseries__missing_required_args"
582583
)
583584
}
584585

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

10111011
if (sum(!is.null(issues), !is.null(lag), !is.null(as_of)) > 1) {
1012-
stop("`issues`, `lag`, and `as_of` are mutually exclusive")
1012+
cli::cli_abort(
1013+
"`issues`, `lag`, and `as_of` are mutually exclusive",
1014+
class = "epidatr__pub_covidcast__too_many_issue_params"
1015+
)
10131016
}
10141017

10151018
assert_character_param("data_source", source, len = 1)
@@ -1025,6 +1028,13 @@ pub_covidcast <- function(
10251028
as_of <- parse_timeset_input(as_of)
10261029
issues <- parse_timeset_input(issues)
10271030

1031+
if (source == "nchs-mortality" && time_type != "week") {
1032+
cli::cli_abort(
1033+
"{source} data is only available at the week level",
1034+
class = "epidatr__nchs_week_only"
1035+
)
1036+
}
1037+
10281038
create_epidata_call(
10291039
"covidcast/",
10301040
list(
@@ -1051,8 +1061,14 @@ pub_covidcast <- function(
10511061
c("day", "week")
10521062
),
10531063
create_epidata_field_info("geo_value", "text"),
1054-
create_epidata_field_info("time_value", "date"),
1055-
create_epidata_field_info("issue", "date"),
1064+
create_epidata_field_info("time_value", switch(time_type,
1065+
day = "date",
1066+
week = "epiweek"
1067+
)),
1068+
create_epidata_field_info("issue", switch(time_type,
1069+
day = "date",
1070+
week = "epiweek"
1071+
)),
10561072
create_epidata_field_info("lag", "int"),
10571073
create_epidata_field_info("value", "float"),
10581074
create_epidata_field_info("stderr", "float"),

R/epidatr-package.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88
"_PACKAGE"
99

1010
.onLoad <- function(libname, pkgname) {
11-
cache_environ$use_cache <- Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE)
12-
cache_environ$use_cache <- (cache_environ$use_cache == "TRUE")
11+
cache_environ$use_cache <- as.logical(Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE))
12+
if (is.na(cache_environ$use_cache)) {
13+
cli::cli_warn(
14+
"Failed to read EPIDATR_USE_CACHE environment variable.
15+
Should be a logical. Defaulting to FALSE."
16+
)
17+
cache_environ$use_cache <- FALSE
18+
}
1319
if (cache_environ$use_cache) {
1420
set_cache(startup = TRUE)
1521
}

R/model.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ parse_data_frame <- function(epidata_call, df, disable_date_parsing = FALSE) {
239239
#' @importFrom MMWRweek MMWRweek
240240
#' @keywords internal
241241
date_to_epiweek <- function(value) {
242-
date_components <- MMWRweek::MMWRweek(as.Date(as.character(value), "%Y%m%d"))
242+
date_components <- MMWRweek::MMWRweek(parse_api_date(value))
243243
as.numeric(paste0(
244244
date_components$MMWRyear,
245245
# Pad with zeroes up to 2 digits (x -> 0x)

_pkgdown.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# Colors should stay consistent across epipredict & epidatr, using Carnegie
2-
# Red https://www.cmu.edu/brand/brand-guidelines/visual-identity/colors.html
1+
# Colors should stay consistent across epipredict, epiprocess, and epidatr,
2+
# using Carnegie Red
3+
# https://www.cmu.edu/brand/brand-guidelines/visual-identity/colors.html
34

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

2022
navbar:
2123
bg: primary
22-
type: dark
24+
type: light
25+
26+
url: https://cmu-delphi.github.io/epidatr/
2327

2428
home:
2529
links:

man/epidatr-package.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/pub_covidcast.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)