Skip to content

Commit 7530486

Browse files
authored
use local file to update NSSP data (#55)
1 parent eaee58f commit 7530486

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export(check_changes_for_autoapproval)
55
export(excluded_locations)
66
export(generate_hub_baseline)
77
export(generate_hub_ensemble)
8+
export(generate_oracle_output)
89
export(get_hub_name)
910
export(included_locations)
1011
export(update_authorized_users)

R/generate_oracle_output.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ flatten_task_list <- function(task_list, .deduplicate = TRUE) {
6969
#' @param hub_path Path to the hub root.
7070
#'
7171
#' @return nothing, invisibly, on success.
72-
#" @export
72+
#' @export
7373
generate_oracle_output <- function(hub_path) {
7474
output_dirpath <- fs::path(hub_path, "target-data")
7575
fs::dir_create(output_dirpath)

R/update_hub_target_data.R

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ nssp_col_names <- list(
2424
#' is "2024-11-09".
2525
#' @param legacy_file Logical. Whether to write legacy
2626
#' CSV output (default: FALSE).
27+
#' @param nssp_update_local Logical. Whether to update NSSP
28+
#' data from local file `auxiliary-data/latest.csv`
29+
#' (default: FALSE).
2730
#'
2831
#' @return Writes `time-series.parquet` and optionally
2932
#' legacy CSV target data files to the target-data
@@ -35,7 +38,8 @@ update_hub_target_data <- function(
3538
as_of = lubridate::today(),
3639
nhsn_first_weekending_date = lubridate::as_date("2024-11-09"),
3740
included_locations = hubhelpr::included_locations,
38-
legacy_file = FALSE
41+
legacy_file = FALSE,
42+
nssp_update_local = FALSE
3943
) {
4044
if (!disease %in% c("covid", "rsv")) {
4145
stop("'disease' must be either 'covid' or 'rsv'")
@@ -90,11 +94,31 @@ update_hub_target_data <- function(
9094
)
9195
}
9296

93-
hubverse_format_nssp_data <- forecasttools::pull_data_cdc_gov_dataset(
94-
dataset = "nssp_prop_ed_visits",
95-
columns = c(nssp_col_name, "geography"),
96-
locations = "All"
97-
) |>
97+
if (nssp_update_local) {
98+
raw_nssp_data <- forecasttools::read_tabular(
99+
fs::path(
100+
base_hub_path,
101+
"auxiliary-data",
102+
"nssp-raw-data",
103+
"latest",
104+
ext = "csv"
105+
)
106+
) |>
107+
dplyr::filter(county == "All") |>
108+
dplyr::select(
109+
week_end,
110+
geography,
111+
dplyr::all_of(nssp_col_name)
112+
)
113+
} else {
114+
raw_nssp_data <- forecasttools::pull_data_cdc_gov_dataset(
115+
dataset = "nssp_prop_ed_visits",
116+
columns = c(nssp_col_name, "geography"),
117+
locations = "All"
118+
)
119+
}
120+
121+
hubverse_format_nssp_data <- raw_nssp_data |>
98122
dplyr::mutate(
99123
date = lubridate::as_date(.data$week_end),
100124
observation = as.numeric(.data[[nssp_col_name]]) / 100,

man/update_hub_target_data.Rd

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

0 commit comments

Comments
 (0)