Skip to content

Commit 50ecf7b

Browse files
committed
comment out broken out half working shit
1 parent e64b984 commit 50ecf7b

File tree

3 files changed

+98
-88
lines changed

3 files changed

+98
-88
lines changed

R/aux_data_utils.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,14 @@ gen_ili_data <- function(default_day_of_week = 1) {
595595
}
596596

597597
process_nhsn_data <- function(raw_nhsn_data) {
598+
# These are exception dates when the data was available on a different day
599+
# than usual. In these two cases, it was the Thursday after. But to keep
600+
# the rest of the pipeline the same, we pretend it was available on Wednesday.
601+
remap_exceptions <- list(
602+
"2024-12-26" = "2024-12-25",
603+
"2025-01-02" = "2025-01-01"
604+
)
605+
fixed_version <- remap_exceptions[[as.character(Sys.Date())]] %||% Sys.Date()
598606
raw_nhsn_data %>%
599607
mutate(
600608
geo_value = tolower(jurisdiction),
@@ -606,6 +614,6 @@ process_nhsn_data <- function(raw_nhsn_data) {
606614
select(-weekendingdate, -jurisdiction, -starts_with("totalconf")) %>%
607615
pivot_longer(cols = starts_with("nhsn"), names_to = "disease") %>%
608616
filter(!is.na(value)) %>%
609-
mutate(version = Sys.Date()) %>%
617+
mutate(version = fixed_version) %>%
610618
relocate(geo_value, disease, time_value, version)
611619
}

scripts/covid_hosp_prod.R

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ insufficient_data_geos <- c("as", "mp", "vi", "gu")
88
# date to cut the truth data off at, so we don't have too much of the past
99
truth_data_date <- "2023-09-01"
1010
# Generically set the generation date to the next Wednesday (or today if it's Wednesday)
11-
forecast_generation_date <- seq.Date(as.Date("2024-11-20"), Sys.Date(), by = 7L)
11+
forecast_generation_date <- Sys.Date() - 1
1212

1313
forecaster_fns <- list2(
1414
linear = function(...) {
@@ -134,23 +134,23 @@ rlang::list2(
134134
},
135135
cue = tar_cue(mode = "always")
136136
),
137-
tar_target(
138-
name = make_climate_submission_csv,
139-
command = {
140-
forecasts <- forecast_res
141-
forecasts %>%
142-
filter(forecaster %in% c("climate_base", "climate_geo_agged")) %>%
143-
group_by(geo_value, target_end_date, quantile) %>%
144-
summarize(forecast_date = first(forecast_date), value = mean(value, na.rm = TRUE), .groups = "drop") %>%
145-
ungroup() %>%
146-
format_flusight(disease = "covid") %>%
147-
write_submission_file(
148-
get_forecast_reference_date(as.Date(forecast_generation_date)),
149-
file.path(submission_directory, "model-output/CMU-climatological-baseline")
150-
)
151-
},
152-
cue = tar_cue(mode = "always")
153-
),
137+
# tar_target(
138+
# name = make_climate_submission_csv,
139+
# command = {
140+
# forecasts <- forecast_res
141+
# forecasts %>%
142+
# filter(forecaster %in% c("climate_base", "climate_geo_agged")) %>%
143+
# group_by(geo_value, target_end_date, quantile) %>%
144+
# summarize(forecast_date = first(forecast_date), value = mean(value, na.rm = TRUE), .groups = "drop") %>%
145+
# ungroup() %>%
146+
# format_flusight(disease = "covid") %>%
147+
# write_submission_file(
148+
# get_forecast_reference_date(as.Date(forecast_generation_date)),
149+
# file.path(submission_directory, "model-output/CMU-climatological-baseline")
150+
# )
151+
# },
152+
# cue = tar_cue(mode = "always")
153+
# ),
154154
tar_target(
155155
name = validate_result,
156156
command = {
@@ -159,30 +159,31 @@ rlang::list2(
159159
if (submission_directory != "cache") {
160160
validation <- validate_submission(
161161
submission_directory,
162-
file_path = sprintf("CMU-TimeSeries/%s-CMU-TimeSeries.csv", get_forecast_reference_date(as.Date(forecast_generation_date))))
163-
} else {
164-
validation <- "not validating when there is no hub (set submission_directory)"
165-
}
166-
validation
167-
},
168-
cue = tar_cue(mode = "always")
169-
),
170-
tar_target(
171-
name = validate_climate_result,
172-
command = {
173-
make_climate_submission_csv
174-
# only validate if we're saving the result to a hub
175-
if (submission_directory != "cache") {
176-
validation <- validate_submission(
177-
submission_directory,
178-
file_path = sprintf("CMU-climatological-baseline/%s-CMU-climatological-baseline.csv", get_forecast_reference_date(as.Date(forecast_generation_date))))
162+
file_path = sprintf("CMU-TimeSeries/%s-CMU-TimeSeries.csv", get_forecast_reference_date(as.Date(forecast_generation_date)))
163+
)
179164
} else {
180165
validation <- "not validating when there is no hub (set submission_directory)"
181166
}
182167
validation
183168
},
184169
cue = tar_cue(mode = "always")
185170
),
171+
# tar_target(
172+
# name = validate_climate_result,
173+
# command = {
174+
# make_climate_submission_csv
175+
# # only validate if we're saving the result to a hub
176+
# if (submission_directory != "cache") {
177+
# validation <- validate_submission(
178+
# submission_directory,
179+
# file_path = sprintf("CMU-climatological-baseline/%s-CMU-climatological-baseline.csv", get_forecast_reference_date(as.Date(forecast_generation_date))))
180+
# } else {
181+
# validation <- "not validating when there is no hub (set submission_directory)"
182+
# }
183+
# validation
184+
# },
185+
# cue = tar_cue(mode = "always")
186+
# ),
186187
tar_target(
187188
name = truth_data,
188189
command = {

scripts/flu_hosp_prod.R

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ truth_data_date <- "2023-09-01"
99
# needed to create the aux data targets
1010
end_date <- Sys.Date()
1111
# Generically set the generation date to the next Wednesday (or today if it's Wednesday)
12-
forecast_generation_date <- seq.Date(as.Date("2024-11-20"), Sys.Date(), by = 7L)
12+
forecast_generation_date <- Sys.Date() - 1
13+
1314
very_latent_locations <- list(list(
1415
c("source"),
1516
c("flusurv", "ILI+")
@@ -98,22 +99,22 @@ rlang::list2(
9899
},
99100
cue = tar_cue(mode = "always")
100101
),
101-
tar_target(
102-
name = nhsn_archive_data,
103-
command = {
104-
qs::qread(here::here("cache/nhsn_archive.parquet")) %>%
105-
add_season_info() %>%
106-
mutate(
107-
source = "nhsn",
108-
geo_value = ifelse(geo_value == "usa", "us", geo_value),
109-
value = nhsn_flu,
110-
time_value = time_value - 3
111-
) %>%
112-
select(geo_value, time_value, version, value, epiweek, epiyear, season, season_week, source) %>%
113-
drop_na() %>%
114-
as_epi_archive(other_keys = "source", compactify = TRUE)
115-
}
116-
),
102+
# tar_target(
103+
# name = nhsn_archive_data,
104+
# command = {
105+
# qs::qread(here::here("cache/nhsn_archive.parquet")) %>%
106+
# add_season_info() %>%
107+
# mutate(
108+
# source = "nhsn",
109+
# geo_value = ifelse(geo_value == "usa", "us", geo_value),
110+
# value = nhsn_flu,
111+
# time_value = time_value - 3
112+
# ) %>%
113+
# select(geo_value, time_value, version, value, epiweek, epiyear, season, season_week, source) %>%
114+
# drop_na() %>%
115+
# as_epi_archive(other_keys = "source", compactify = TRUE)
116+
# }
117+
# ),
117118
tar_map(
118119
values = tidyr::expand_grid(tibble(forecast_generation_date = forecast_generation_date)),
119120
names = "forecast_generation_date",
@@ -139,7 +140,7 @@ rlang::list2(
139140
command = {
140141
forecast_date <- as.Date(forecast_generation_date)
141142
if (forecast_date < Sys.Date()) {
142-
train_data <- nhsn_archive_data %>% epix_as_of(forecast_date)
143+
# train_data <- nhsn_archive_data %>% epix_as_of(forecast_date)
143144
} else {
144145
train_data <- nhsn_latest_data
145146
}
@@ -195,23 +196,23 @@ rlang::list2(
195196
},
196197
cue = tar_cue(mode = "always")
197198
),
198-
tar_target(
199-
name = make_climate_submission_csv,
200-
command = {
201-
forecasts <- forecast_res
202-
forecasts %>%
203-
filter(forecaster %in% c("climate_base", "climate_geo_agged")) %>%
204-
group_by(geo_value, target_end_date, quantile) %>%
205-
summarize(forecast_date = first(forecast_date), value = mean(value, na.rm = TRUE), .groups = "drop") %>%
206-
ungroup() %>%
207-
format_flusight(disease = "flu") %>%
208-
write_submission_file(
209-
get_forecast_reference_date(as.Date(forecast_generation_date)),
210-
file.path(submission_directory, "model-output/CMU-climatological-baseline")
211-
)
212-
},
213-
cue = tar_cue(mode = "always")
214-
),
199+
# tar_target(
200+
# name = make_climate_submission_csv,
201+
# command = {
202+
# forecasts <- forecast_res
203+
# forecasts %>%
204+
# filter(forecaster %in% c("climate_base", "climate_geo_agged")) %>%
205+
# group_by(geo_value, target_end_date, quantile) %>%
206+
# summarize(forecast_date = first(forecast_date), value = mean(value, na.rm = TRUE), .groups = "drop") %>%
207+
# ungroup() %>%
208+
# format_flusight(disease = "flu") %>%
209+
# write_submission_file(
210+
# get_forecast_reference_date(as.Date(forecast_generation_date)),
211+
# file.path(submission_directory, "model-output/CMU-climatological-baseline")
212+
# )
213+
# },
214+
# cue = tar_cue(mode = "always")
215+
# ),
215216
tar_target(
216217
name = validate_result,
217218
command = {
@@ -229,23 +230,23 @@ rlang::list2(
229230
},
230231
cue = tar_cue(mode = "always")
231232
),
232-
tar_target(
233-
name = validate_climate_result,
234-
command = {
235-
make_climate_submission_csv
236-
# only validate if we're saving the result to a hub
237-
if (submission_directory != "cache") {
238-
validation <- validate_submission(
239-
submission_directory,
240-
file_path = sprintf("CMU-climatological-baseline/%s-CMU-climatological-baseline.csv", get_forecast_reference_date(as.Date(forecast_generation_date)))
241-
)
242-
} else {
243-
validation <- "not validating when there is no hub (set submission_directory)"
244-
}
245-
validation
246-
},
247-
cue = tar_cue(mode = "always")
248-
),
233+
# tar_target(
234+
# name = validate_climate_result,
235+
# command = {
236+
# make_climate_submission_csv
237+
# # only validate if we're saving the result to a hub
238+
# if (submission_directory != "cache") {
239+
# validation <- validate_submission(
240+
# submission_directory,
241+
# file_path = sprintf("CMU-climatological-baseline/%s-CMU-climatological-baseline.csv", get_forecast_reference_date(as.Date(forecast_generation_date)))
242+
# )
243+
# } else {
244+
# validation <- "not validating when there is no hub (set submission_directory)"
245+
# }
246+
# validation
247+
# },
248+
# cue = tar_cue(mode = "always")
249+
# ),
249250
tar_target(
250251
name = truth_data,
251252
command = {

0 commit comments

Comments
 (0)