@@ -16,15 +16,15 @@ end_date <- Sys.Date()
16
16
# today, which is a Wednesday. Sometimes, if we're doing a delayed forecast,
17
17
# it's a Thursday. It's used for stamping the data and for determining the
18
18
# appropriate as_of when creating the forecast.
19
- forecast_generation_date <- Sys.Date()
19
+ forecast_generation_dates <- Sys.Date()
20
20
# Usually, the forecast_date is the same as the generation date, but you can
21
21
# override this. It should be a Wednesday.
22
- forecast_date <- round_date(forecast_generation_date , " weeks" , week_start = 3 )
22
+ forecast_dates <- round_date(forecast_generation_dates , " weeks" , week_start = 3 )
23
23
# If doing backfill, you can set the forecast_date to a sequence of dates.
24
- # forecast_date <- seq.Date(as.Date("2024-11-20"), Sys.Date(), by = 7L)
24
+ # forecast_dates <- seq.Date(as.Date("2024-11-20"), Sys.Date(), by = 7L)
25
25
# forecast_generation_date needs to follow suit, but it's more complicated
26
26
# because sometimes we forecast on Thursday.
27
- # forecast_generation_date <- c(as.Date(c("2024-11-21", "2024-11-27", "2024-12-04", "2024-12-11", "2024-12-18", "2024-12-26", "2025-01-02")), seq.Date(as.Date("2025-01-08"), Sys.Date(), by = 7L))
27
+ # forecast_generation_dates <- c(as.Date(c("2024-11-21", "2024-11-27", "2024-12-04", "2024-12-11", "2024-12-18", "2024-12-26", "2025-01-02")), seq.Date(as.Date("2025-01-08"), Sys.Date(), by = 7L))
28
28
29
29
# Whether we're running in backtest mode.
30
30
# If TRUE, we don't run the report notebook, which is (a) slow and (b) should be
@@ -167,15 +167,15 @@ rlang::list2(
167
167
tar_map(
168
168
# Because targets relies on R metaprogramming, it loses the Date class.
169
169
values = tibble(
170
- forecast_date_int = forecast_date ,
171
- forecast_generation_date_int = forecast_generation_date ,
172
- forecast_date_chr = as.character(forecast_date_int )
170
+ forecast_date_int = forecast_dates ,
171
+ forecast_generation_date_int = forecast_generation_dates ,
172
+ forecast_date_chr = as.character(forecast_dates )
173
173
),
174
174
names = " forecast_date_chr" ,
175
175
tar_change(
176
176
name = geo_forecasters_weights ,
177
177
command = {
178
- geo_forecasters_weights <- parse_prod_weights(here :: here(" flu_geo_exclusions.csv" ), forecast_date_int , forecaster_fns )
178
+ geo_forecasters_weights <- parse_prod_weights(here :: here(" flu_geo_exclusions.csv" ), forecast_date_int , names( forecaster_fns ) )
179
179
if (nrow(geo_forecasters_weights %> % filter(forecast_date == as.Date(forecast_date_int ))) == 0 ) {
180
180
cli_abort(" there are no weights for the forecast date {forecast_date}" )
181
181
}
@@ -342,25 +342,27 @@ rlang::list2(
342
342
tar_target(
343
343
name = make_submission_csv ,
344
344
command = {
345
- if (! backtest_mode ) {
345
+ if (! backtest_mode && submission_directory != " cache " ) {
346
346
combo_ens_climate_linear_window_season %> %
347
347
format_flusight(disease = " flu" ) %> %
348
348
write_submission_file(
349
349
get_forecast_reference_date(forecast_date_int ),
350
350
file.path(submission_directory , " model-output/CMU-TimeSeries" )
351
351
)
352
+ } else {
353
+ cli_alert_info(" Not making submission csv because we're in backtest mode or submission directory is cache" )
352
354
}
353
355
}
354
356
),
355
357
tar_target(
356
358
name = make_climate_submission_csv ,
357
359
command = {
358
- if (! backtest_mode ) {
360
+ if (! backtest_mode && submission_directory != " cache " ) {
359
361
forecasts <- forecast_res
360
362
forecasts %> %
361
363
filter(forecaster %in% c(" climate_base" , " climate_geo_agged" )) %> %
362
364
group_by(geo_value , target_end_date , quantile ) %> %
363
- summarize(forecast_date = first( forecast_date ), value = mean(value , na.rm = TRUE ), .groups = " drop" ) %> %
365
+ summarize(forecast_date = as.Date( forecast_date_int ), value = mean(value , na.rm = TRUE ), .groups = " drop" ) %> %
364
366
ungroup() %> %
365
367
filter(! (geo_value %in% excluded_geos )) %> %
366
368
format_flusight(disease = " flu" ) %> %
@@ -370,6 +372,8 @@ rlang::list2(
370
372
submission_directory = file.path(submission_directory , " model-output/CMU-climate_baseline" ),
371
373
file_name = " CMU-climate_baseline"
372
374
)
375
+ } else {
376
+ cli_alert_info(" Not making climate submission csv because we're in backtest mode or submission directory is cache" )
373
377
}
374
378
},
375
379
priority = 0.99
@@ -468,10 +472,11 @@ rlang::list2(
468
472
cue = tar_cue(mode = " always" )
469
473
)
470
474
),
471
- tar_target(
472
- new_data_notebook ,
473
- command = {
474
- rmarkdown :: render(" scripts/reports/new_data.Rmd" , output_file = here :: here(" reports" , " new_data.html" ))
475
- }
476
- )
475
+ # TODO
476
+ # tar_target(
477
+ # new_data_notebook,
478
+ # command = {
479
+ # rmarkdown::render("scripts/reports/new_data.Rmd", output_file = here::here("reports", "new_data.html"))
480
+ # }
481
+ # )
477
482
)
0 commit comments