Skip to content

Commit ae3d1b2

Browse files
committed
Merge branch 'dev' into ndefries/hosp-state-take_as_of
2 parents a7091c2 + 73ea679 commit ae3d1b2

Some content is hidden

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

45 files changed

+325
-167
lines changed

.github/workflows/pkgdown.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# update the documentation web site on pushes to `dev` branch.
66
on:
77
push:
8-
branches: [dev]
8+
branches: [main, dev]
99
pull_request:
10-
branches: [dev]
10+
branches: [main, dev]
1111
release:
1212
types: [published]
1313
workflow_dispatch:

DESCRIPTION

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Package: epidatr
22
Type: Package
33
Title: Client for Delphi's 'Epidata' API
4-
Version: 1.1.0
4+
Version: 1.1.0.9000
55
Date: 2023-09-11
6-
Authors@R:
6+
Authors@R:
77
c(
88
person("Logan", "Brooks", email = "lcbrooks@andrew.cmu.edu", role = c("aut")),
99
person("Dmitry", "Shemetov", email = "dshemeto@andrew.cmu.edu", role = c("aut")),
@@ -37,6 +37,7 @@ Imports:
3737
openssl,
3838
readr,
3939
tibble,
40+
usethis,
4041
xml2
4142
RoxygenNote: 7.2.3
4243
Suggests:
@@ -50,7 +51,7 @@ Suggests:
5051
VignetteBuilder: knitr
5152
Language: en-US
5253
Config/testthat/edition: 3
53-
Collate:
54+
Collate:
5455
'auth.R'
5556
'avail_endpoints.R'
5657
'cache.R'

DEVELOPMENT.md

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,52 @@
1-
## Development Environment
2-
3-
Relevant R commands
1+
## Setting up the development environment
42

53
```r
64
install.packages(c('devtools', 'pkgdown', 'styler', 'lintr')) # install dev dependencies
75
devtools::install_deps(dependencies = TRUE) # install package dependencies
86
devtools::document() # generate package meta data and man files
97
devtools::build() # build package
8+
9+
```
10+
11+
## Validating the package
12+
13+
```r
1014
styler::style_pkg() # format code
11-
lintr::lint_package() # lint package
15+
lintr::lint_package() # lint code
16+
1217
devtools::test() # test package
1318
devtools::check() # check package for errors
1419
```
1520

16-
## Release Process
21+
## Developing the documentation site
22+
23+
The [documentation site](https://cmu-delphi.github.io/epidatr/) is built off of the `main` branch. The `dev` version of the site is available at https://cmu-delphi.github.io/epidatr/dev.
24+
25+
The documentation site can be previewed locally by running in R
26+
27+
```r
28+
pkgdown::build_site(preview=TRUE)
29+
```
30+
31+
The `main` version is available at `file:///<local path>/epidatr/docs/index.html` and `dev` at `file:///<local path>/epidatr/docs/dev/index.html`.
32+
33+
You can also build the docs manually and launch the site with python. From the terminal, this looks like
34+
```bash
35+
R -e 'devtools::document()'
36+
python -m http.server -d docs
37+
```
38+
39+
For `pkgdown` to correctly generate both public (`main`) and `dev` documentation sites, the package version in `DESCRIPTION` on `dev` must have four components, and be of the format `x.x.x.9000`. The package version on `main` must be in the format `x.x.x`.
40+
41+
The documentation website is updated on push or pull request to the `main` and `dev` branches.
42+
43+
## Release process
44+
45+
### Manual
46+
47+
TBD
48+
49+
### Automated (currently unavailable)
1750

1851
The release consists of multiple steps which can be all done via the GitHub website:
1952

@@ -25,8 +58,3 @@ The release consists of multiple steps which can be all done via the GitHub webs
2558
2. create another [Pull Request](https://github.com/cmu-delphi/epidatr/pulls) to merge the changes back to the `dev` branch
2659
3. create a [GitHub release](https://github.com/cmu-delphi/epidatr/releases) with automatically derived release notes
2760
5. Release to CRAN
28-
29-
[mit-image]: https://img.shields.io/badge/License-MIT-yellow.svg
30-
[mit-url]: https://opensource.org/license/MIT
31-
[github-actions-image]: https://github.com/cmu-delphi/epidatr/workflows/ci/badge.svg
32-
[github-actions-url]: https://github.com/cmu-delphi/epidatr/actions

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export(pvt_norostat)
4444
export(pvt_quidel)
4545
export(pvt_sensors)
4646
export(pvt_twitter)
47-
export(set_api_key)
47+
export(save_api_key)
4848
export(set_cache)
4949
import(cachem)
5050
import(glue)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# epidatr 1.1.0
2+
23
- renamed the mostly internal `get_auth_key` to `get_api_key`
3-
- added `set_api_key` to more easily set the option
4+
- added `save_api_key` to more easily set the option
45
- various CRAN submission related doc-fixes
56
- fixed some errors from passing "" as a key
67

R/auth.R

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,28 @@
1010
#' please consider [registering for an API
1111
#' key](https://api.delphi.cmu.edu/epidata/admin/registration_form).
1212
#'
13-
#' API keys are strings and can be set in two ways. If the environment variable
14-
#' `DELPHI_EPIDATA_KEY` is set, it will be used automatically. Environment
15-
#' variables can be set either in the shell or by editing your `.Renviron` file,
16-
#' which will ensure the setting applies to all R sessions. See `?Startup` for a
17-
#' description of `Renviron` files and where they can be placed.
18-
#'
19-
#' Alternately, the API key can be set from within a session by using
20-
#' `set_api_key()`, which sets the R option `delphi.epidata.key` using
21-
#' `options()`. If this option is set, it is used in preference to the
22-
#' environment variable, so you may change keys within an R session. R options
23-
#' are not preserved between sessions, so `set_api_key()` must be run every time
24-
#' you open R. Alternately, you can have R set the option at startup by adding
25-
#' it to your `.Rprofile`; see `?Startup` for a description of `Rprofile` files
26-
#' and where they can be placed.
13+
#' API keys are strings read from the environment variable `DELPHI_EPIDATA_KEY`.
14+
#' We recommend setting your key with `save_api_key()`, which will modify an
15+
#' applicable `.Renviron` file, which will be read in automatically when you
16+
#' start future R sessions (see [`?Startup`][base::Startup] for details on
17+
#' `.Renviron` files). Alternatively, you can modify the environment variable at
18+
#' the command line before/while launching R, or inside an R session with
19+
#' [`Sys.setenv()`], but these will not persist across sessions.
2720
#'
2821
#' Once an API key is set, it is automatically used for all requests made by
2922
#' functions in this package.
3023
#'
3124
#' @return For `get_api_key()`, returns the current API key as a string, or
3225
#' `""` if none is set.
3326
#'
34-
#' @seealso [usethis::edit_r_environ()] to automatically edit the `.Renviron`
35-
#' file; [usethis::edit_r_profile()] to automatically edit the `.Rprofile`
36-
#' file
37-
#'
38-
#' @references Delphi Epidata API Keys documentation.
39-
#' <https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html>
27+
#' @references
28+
#' - [Delphi Epidata API Keys
29+
#' documentation](https://cmu-delphi.github.io/delphi-epidata/api/api_keys.html).
30+
#' - [Delphi Epidata API Registration
31+
#' Form](https://api.delphi.cmu.edu/epidata/admin/registration_form).
4032
#'
41-
#' Delphi Epidata API Registration Form.
42-
#' <https://api.delphi.cmu.edu/epidata/admin/registration_form>
4333
#' @export
4434
get_api_key <- function() {
45-
key <- getOption("delphi.epidata.key", default = "")
46-
if (key != "") {
47-
return(key)
48-
}
49-
5035
key <- Sys.getenv("DELPHI_EPIDATA_KEY", unset = "")
5136
if (key != "") {
5237
return(key)
@@ -55,7 +40,7 @@ get_api_key <- function() {
5540
cli::cli_warn(
5641
c(
5742
"No API key found. You will be limited to non-complex queries and encounter rate limits if you proceed.",
58-
"i" = "See {.help set_api_key} for details on obtaining and setting API keys."
43+
"i" = "See {.help save_api_key} for details on obtaining and setting API keys."
5944
),
6045
.frequency = "regularly",
6146
.frequency_id = "delphi.epidata.key"
@@ -64,8 +49,29 @@ get_api_key <- function() {
6449
}
6550

6651
#' @rdname get_api_key
67-
#' @param key API key to use for future requests
6852
#' @export
69-
set_api_key <- function(key) {
70-
options(delphi.epidata.key = key)
53+
save_api_key <- function() {
54+
cli::cli_inform(
55+
c(
56+
"i" = "This function will open your {.code .Renviron} file in a text editor. You will need to
57+
write {.code DELPHI_EPIDATA_KEY=yourkeyhere} (without quotes) in the file and save it. If the editor
58+
does not open, you will need to edit the file manually.",
59+
"i" = "Press enter to continue."
60+
)
61+
)
62+
readline()
63+
64+
if (file.exists(usethis::proj_path(".Renviron"))) {
65+
usethis::edit_r_environ(scope = "project")
66+
67+
cat("\n\n")
68+
cli::cli_inform(
69+
c(
70+
"i" = "Your project {.code .Renviron} file has been updated. Make sure not to share this
71+
file (add it to .gitignore or equivalents)."
72+
)
73+
)
74+
} else {
75+
usethis::edit_r_environ(scope = "user")
76+
}
7177
}

R/avail_endpoints.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ avail_endpoints <- function() {
2222
Endpoint = paste0(h$Name, "()"),
2323
Description = h$Title
2424
)
25+
cli::cli_inform(c("i" = "Data is available for the US only, unless otherwise specified"))
2526
tib %>% print(n = 50)
2627
}

R/covidcast.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ print.covidcast_data_source <- function(x, ...) {
127127
#' ```
128128
#'
129129
#' These objects can be used directly to fetch data, without requiring us to use
130-
#' the `covidcast()` function. Simply use the `$call` attribute of the object:
130+
#' the `pub_covidcast()` function. Simply use the `$call` attribute of the object:
131131
#'
132132
#' ```{r}
133133
#' epidata$signals$`fb-survey:smoothed_cli`$call("state", "pa",

0 commit comments

Comments
 (0)