@@ -148,16 +148,12 @@ get_forecast_dates <- function(forecasters,
148
148
start_date ,
149
149
end_date ,
150
150
date_filtering_function ) {
151
- forecast_dates <- as_date(forecast_dates )
152
151
forecaster_dates <- vector(" list" , length = length(forecasters ))
153
152
for (i in seq_len(length(forecasters ))) {
154
- forecaster_dates [[i ]] <- tryCatch({
155
- lubridate :: as_date(get_covidhub_forecast_dates(forecasters [i ]))
156
- },
157
- error = function (e ) cat(sprintf(" %i. %s\n " , i , e $ message ))
158
- )
153
+ forecaster_dates [[i ]] <- lubridate :: as_date(get_covidhub_forecast_dates(forecasters [i ]))
159
154
}
160
155
if (length(forecast_dates ) != 0 ) {
156
+ forecast_dates <- as_date(forecast_dates )
161
157
# Intersect acts oddly with dates. If foo = as_date(bar), then foo == bar is
162
158
# true, but (foo %in% bar) is false and intersect(foo, bar) is an empty
163
159
# vector. Additionally, intersect returns a numeric object instead of a
@@ -431,6 +427,8 @@ get_forecaster_predictions_alt <- function(covidhub_forecaster_name,
431
427
# '
432
428
# ' @return vector of forecast dates
433
429
# '
430
+ # ' @importFrom httr GET RETRY
431
+ # '
434
432
# ' @export
435
433
get_covidhub_forecast_dates <- function (forecaster_name ) {
436
434
url <- " https://api.github.com/repos/reichlab/covid19-forecast-hub/git/trees/master"
@@ -451,25 +449,28 @@ get_covidhub_forecast_dates <- function(forecaster_name) {
451
449
452
450
# Get the URL for the submissions folder "data-processed".
453
451
submissions_folder <- url %> %
454
- httr :: GET( auth_header ) %> %
452
+ RETRY( " GET " , url = . , auth_header ) %> %
455
453
is_rate_limit_exceeded() %> %
454
+ httr :: stop_for_status() %> %
456
455
httr :: content() %> %
457
456
purrr :: pluck(" tree" ) %> %
458
457
magrittr :: extract2(which(purrr :: map_chr(. , " path" ) == " data-processed" ))
459
458
460
459
# Get the URL for the specified forecaster folder.
461
460
forecaster_folder <- submissions_folder $ url %> %
462
- httr :: GET( auth_header ) %> %
461
+ RETRY( " GET " , url = . , auth_header ) %> %
463
462
is_rate_limit_exceeded() %> %
463
+ httr :: stop_for_status() %> %
464
464
httr :: content() %> %
465
465
purrr :: pluck(" tree" ) %> %
466
466
magrittr :: extract2(which(purrr :: map_chr(. , " path" ) == forecaster_name ))
467
467
468
468
# Get the forecaster submission files.
469
469
submission_file_pattern <- sprintf(" ^(20\\ d{2}-\\ d{2}-\\ d{2})-%s.csv$" , forecaster_name )
470
470
submission_files <- forecaster_folder $ url %> %
471
- httr :: GET( auth_header ) %> %
471
+ RETRY( " GET " , url = . , auth_header ) %> %
472
472
is_rate_limit_exceeded() %> %
473
+ httr :: stop_for_status() %> %
473
474
httr :: content() %> %
474
475
purrr :: pluck(" tree" ) %> %
475
476
purrr :: map_chr(" path" ) %> %
0 commit comments