Skip to content

Commit 7f2d73a

Browse files
authored
Merge pull request #156 from cmu-delphi/ds/merge-fetch
refactor: `fetch` by default
2 parents 3db0081 + a25e532 commit 7f2d73a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1118
-516
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.8.0
2+
current_version = 0.9.0
33
commit = False
44
tag = False
55

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @dshemetov @brookslogan
1+
* @dshemetov @brookslogan @dsweber2

.github/workflows/ci.yml

+1-11
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,7 @@ jobs:
1919

2020
- uses: r-lib/actions/setup-r-dependencies@v2
2121
with:
22-
extra-packages: any::devtools, any::rcmdcheck, any::styler, any::lintr, local::.
23-
24-
- name: Style / Format
25-
shell: Rscript {0}
26-
run: styler::style_pkg(dry="fail")
27-
28-
- name: Lint
29-
shell: Rscript {0}
30-
run: |
31-
devtools::load_all()
32-
lintr::lint_package('.')
22+
extra-packages: any::devtools, any::rcmdcheck, local::.
3323

3424
- uses: r-lib/actions/check-r-package@v2
3525
env:

.github/workflows/document.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
paths: ["R/**"]
6+
7+
name: Document
8+
9+
jobs:
10+
document:
11+
runs-on: ubuntu-latest
12+
env:
13+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup R
21+
uses: r-lib/actions/setup-r@v2
22+
with:
23+
use-public-rspm: true
24+
25+
- name: Install dependencies
26+
uses: r-lib/actions/setup-r-dependencies@v2
27+
with:
28+
extra-packages: any::roxygen2
29+
needs: roxygen2
30+
31+
- name: Document
32+
run: roxygen2::roxygenise()
33+
shell: Rscript {0}
34+
35+
- name: Commit and push changes
36+
run: |
37+
git config --local user.name "$GITHUB_ACTOR"
38+
git config --local user.email "[email protected]"
39+
git add man/\* NAMESPACE DESCRIPTION
40+
git commit -m "docs: update documentation (GHA)" || echo "No changes to commit"
41+
git pull --ff-only
42+
git push origin

.github/workflows/lint.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, master, dev]
6+
pull_request:
7+
branches: [main, master, dev]
8+
9+
name: lint
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
env:
15+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- uses: r-lib/actions/setup-r@v2
20+
with:
21+
use-public-rspm: true
22+
23+
- uses: r-lib/actions/setup-r-dependencies@v2
24+
with:
25+
extra-packages: any::lintr, local::.
26+
needs: lint
27+
28+
- name: Lint
29+
run: lintr::lint_package()
30+
shell: Rscript {0}
31+
env:
32+
LINTR_ERROR_ON_LINT: true

.github/workflows/style.yaml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw", "**.[rR]profile"]
6+
7+
name: Style
8+
9+
jobs:
10+
style:
11+
runs-on: ubuntu-latest
12+
env:
13+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup R
21+
uses: r-lib/actions/setup-r@v2
22+
with:
23+
use-public-rspm: true
24+
25+
- name: Install dependencies
26+
uses: r-lib/actions/setup-r-dependencies@v2
27+
with:
28+
extra-packages: any::styler, any::roxygen2
29+
needs: styler
30+
31+
- name: Enable styler cache
32+
run: styler::cache_activate()
33+
shell: Rscript {0}
34+
35+
- name: Determine cache location
36+
id: styler-location
37+
run: |
38+
cat(
39+
"location=",
40+
styler::cache_info(format = "tabular")$location,
41+
"\n",
42+
file = Sys.getenv("GITHUB_OUTPUT"),
43+
append = TRUE,
44+
sep = ""
45+
)
46+
shell: Rscript {0}
47+
48+
- name: Cache styler
49+
uses: actions/cache@v3
50+
with:
51+
path: ${{ steps.styler-location.outputs.location }}
52+
key: ${{ runner.os }}-styler-${{ github.sha }}
53+
restore-keys: |
54+
${{ runner.os }}-styler-
55+
${{ runner.os }}-
56+
57+
- name: Style
58+
run: styler::style_pkg()
59+
shell: Rscript {0}
60+
61+
- name: Commit and push changes
62+
run: |
63+
if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \
64+
| egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$'))
65+
then
66+
git config --local user.name "$GITHUB_ACTOR"
67+
git config --local user.email "[email protected]"
68+
git commit ${FILES_TO_COMMIT[*]} -m "style: styler (GHA)"
69+
git pull --ff-only
70+
git push origin
71+
else
72+
echo "No changes to commit."
73+
fi

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ env
1616
/doc/
1717
/Meta/
1818
.secrets
19+
epidatr.Rproj

.lintr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
linters: with_defaults(
1+
linters: linters_with_defaults(
22
line_length_linter(120),
33
cyclocomp_linter = NULL
44
)

DESCRIPTION

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: epidatr
22
Type: Package
33
Title: Client for Delphi's Epidata API
4-
Version: 0.8.0
4+
Version: 0.9.0
55
Authors@R:
66
c(
77
person("Logan", "Brooks", email = "[email protected]", role = c("aut", "cre")),
@@ -25,7 +25,6 @@ Imports:
2525
magrittr,
2626
MMWRweek,
2727
readr,
28-
rlang,
2928
tibble,
3029
xml2
3130
RoxygenNote: 7.2.3

NAMESPACE

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export(dengue_nowcast)
1717
export(ecdc_ili)
1818
export(epirange)
1919
export(fetch)
20+
export(fetch_args_list)
2021
export(flusurv)
2122
export(fluview)
2223
export(fluview_clinical)
@@ -38,11 +39,12 @@ export(pvt_quidel)
3839
export(pvt_sensors)
3940
export(pvt_twitter)
4041
export(wiki)
41-
export(with_base_url)
4242
importFrom(MMWRweek,MMWRweek2Date)
4343
importFrom(checkmate,assert)
4444
importFrom(checkmate,assert_character)
4545
importFrom(checkmate,assert_integerish)
46+
importFrom(checkmate,assert_logical)
47+
importFrom(checkmate,assert_numeric)
4648
importFrom(checkmate,check_character)
4749
importFrom(checkmate,check_class)
4850
importFrom(checkmate,check_date)
@@ -63,7 +65,6 @@ importFrom(httr,stop_for_status)
6365
importFrom(jsonlite,fromJSON)
6466
importFrom(magrittr,"%>%")
6567
importFrom(readr,read_csv)
66-
importFrom(rlang,abort)
6768
importFrom(tibble,as_tibble)
6869
importFrom(tibble,tibble)
6970
importFrom(xml2,read_html)

NEWS.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
# epidatr 0.9.0
2+
3+
- Major interface change: all endpoints now fetch by default.
4+
- Make all `fetch` function internal.
5+
- Change `fetch` and `fetch_*` function interfaces now rely on `fetch_args_list`.
6+
- Added `fetch_args_list` which returns a list of arguments to be passed to `fetch`.
7+
18
# epidatr 0.8.0
29

3-
- Fix source name duplication bug in `covidcast_epidata`
4-
- Mark `covidcast_epidata` as experimental and do not export it
5-
- Change `covidcast` arg `data_source` to `source`
6-
- Make `covidcast` args `issues`, `lag`, and `as_of` mutually exclusive
10+
- Fix source name duplication bug in `covidcast_epidata`.
11+
- Mark `covidcast_epidata` as experimental and do not export it.
12+
- Change `covidcast` arg `data_source` to `source`.
13+
- Make `covidcast` args `issues`, `lag`, and `as_of` mutually exclusive.
714
- Make `covid_hosp_facility_lookup` args `state,` `ccn`, `city`, `zip`, and
8-
`fips_code` mutually exclusive
15+
`fips_code` mutually exclusive.
916
- Update documentation to only refer to character or strings (not character
10-
vectors or character strings)
17+
vectors or character strings).
1118

1219
# epidatr 0.7.1
1320

R/auth.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ get_auth_key <- function() {
1717
return(key)
1818
}
1919

20-
rlang::warn(
20+
cli::cli_warn(
2121
c(
22-
"No API key found. You will be limited to non-complex queries and encounter rate limits if you proceed.",
23-
"To avoid this, you can get your key by registering at https://api.delphi.cmu.edu/epidata/admin/registration_form and then:",
22+
"No API key found. You will be limited to non-complex queries and encounter rate limits if you proceed.
23+
To avoid this, you can get your key by registering
24+
at https://api.delphi.cmu.edu/epidata/admin/registration_form and then:",
2425
"i" = "set the environment variable DELPHI_EPIDATA_KEY",
2526
"i" = "set the option 'delphi.epidata.key'",
2627
"",
2728
"To save your key for later sessions (and hide it from your code), you can edit your .Renviron file with:",
2829
"i" = "usethis::edit_r_environ()"
2930
),
30-
use_cli_format = TRUE,
3131
.frequency = "regularly",
3232
.frequency_id = "delphi.epidata.key"
3333
)

R/check.R

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22
#' @importFrom checkmate assert_character assert_integerish
33
#' @keywords internal
44
assert_character_param <- function(name, value, len = NULL, required = TRUE) {
5-
null.ok <- !required
5+
null_ok <- !required
66
assert_integerish(len, null.ok = TRUE, .var.name = "len")
7-
assert_character(value, null.ok = null.ok, len = len, any.missing = FALSE, .var.name = name)
7+
assert_character(value, null.ok = null_ok, len = len, any.missing = FALSE, .var.name = name)
88
}
99

1010
#' Allows integer-like vectors
1111
#' @importFrom checkmate assert_integerish
1212
#' @keywords internal
1313
assert_integerish_param <- function(name, value, len = NULL, required = TRUE) {
14-
null.ok <- !required
14+
null_ok <- !required
1515
assert_integerish(len, null.ok = TRUE, .var.name = "len")
16-
assert_integerish(value, null.ok = null.ok, len = len, any.missing = FALSE, .var.name = name)
16+
assert_integerish(value, null.ok = null_ok, len = len, any.missing = FALSE, .var.name = name)
1717
}
1818

1919
#' Allows a vector of date_like params: date, character, or integer-like
2020
#' @importFrom checkmate check_date check_character check_integerish
2121
#' @keywords internal
2222
assert_date_param <- function(name, value, len = NULL, required = TRUE) {
23-
null.ok <- !required
23+
null_ok <- !required
2424
assert_integerish(len, null.ok = TRUE, .var.name = "len")
2525
assert(
26-
check_date(value, len = len, any.missing = FALSE, null.ok = null.ok),
27-
check_character(value, len = len, any.missing = FALSE, null.ok = null.ok),
28-
check_integerish(value, len = len, any.missing = FALSE, null.ok = null.ok),
26+
check_date(value, len = len, any.missing = FALSE, null.ok = null_ok),
27+
check_character(value, len = len, any.missing = FALSE, null.ok = null_ok),
28+
check_integerish(value, len = len, any.missing = FALSE, null.ok = null_ok),
2929
combine = "or",
3030
.var.name = name
3131
)
@@ -36,19 +36,19 @@ assert_date_param <- function(name, value, len = NULL, required = TRUE) {
3636
#' @importFrom checkmate assert check_character check_date check_integerish check_class check_list check_names
3737
#' @keywords internal
3838
assert_timeset_param <- function(name, value, len = NULL, required = TRUE) {
39-
null.ok <- !required
39+
null_ok <- !required
4040
assert_integerish(len, len = 1L, null.ok = TRUE, .var.name = "len")
4141
assert(
42-
check_class(value, "EpiRange", null.ok = null.ok),
42+
check_class(value, "EpiRange", null.ok = null_ok),
4343
check_names(names(value), type = "unnamed"),
4444
combine = "or",
4545
.var.name = name
4646
)
4747
assert(
48-
check_date(value, len = len, any.missing = FALSE, null.ok = null.ok),
49-
check_character(value, len = len, any.missing = FALSE, null.ok = null.ok),
50-
check_integerish(value, len = len, any.missing = FALSE, null.ok = null.ok),
51-
check_class(value, "EpiRange", null.ok = null.ok),
48+
check_date(value, len = len, any.missing = FALSE, null.ok = null_ok),
49+
check_character(value, len = len, any.missing = FALSE, null.ok = null_ok),
50+
check_integerish(value, len = len, any.missing = FALSE, null.ok = null_ok),
51+
check_class(value, "EpiRange", null.ok = null_ok),
5252
combine = "or",
5353
.var.name = name
5454
)

R/constants.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version <- "0.8.0"
1+
version <- "0.9.0"
22
http_headers <- httr::add_headers("User-Agent" = paste0("epidatr/", version), "Accept-Encoding" = "gzip")
33
global_base_url <- "https://api.delphi.cmu.edu/epidata/"

0 commit comments

Comments
 (0)