@@ -148,16 +148,12 @@ get_forecast_dates <- function(forecasters,
148148 start_date ,
149149 end_date ,
150150 date_filtering_function ) {
151- forecast_dates <- as_date(forecast_dates )
152151 forecaster_dates <- vector(" list" , length = length(forecasters ))
153152 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 ]))
159154 }
160155 if (length(forecast_dates ) != 0 ) {
156+ forecast_dates <- as_date(forecast_dates )
161157 # Intersect acts oddly with dates. If foo = as_date(bar), then foo == bar is
162158 # true, but (foo %in% bar) is false and intersect(foo, bar) is an empty
163159 # vector. Additionally, intersect returns a numeric object instead of a
@@ -431,6 +427,8 @@ get_forecaster_predictions_alt <- function(covidhub_forecaster_name,
431427# '
432428# ' @return vector of forecast dates
433429# '
430+ # ' @importFrom httr GET RETRY
431+ # '
434432# ' @export
435433get_covidhub_forecast_dates <- function (forecaster_name ) {
436434 url <- " https://api.github.com/repos/reichlab/covid19-forecast-hub/git/trees/master"
@@ -451,25 +449,28 @@ get_covidhub_forecast_dates <- function(forecaster_name) {
451449
452450 # Get the URL for the submissions folder "data-processed".
453451 submissions_folder <- url %> %
454- httr :: GET( auth_header ) %> %
452+ RETRY( " GET " , url = . , auth_header ) %> %
455453 is_rate_limit_exceeded() %> %
454+ httr :: stop_for_status() %> %
456455 httr :: content() %> %
457456 purrr :: pluck(" tree" ) %> %
458457 magrittr :: extract2(which(purrr :: map_chr(. , " path" ) == " data-processed" ))
459458
460459 # Get the URL for the specified forecaster folder.
461460 forecaster_folder <- submissions_folder $ url %> %
462- httr :: GET( auth_header ) %> %
461+ RETRY( " GET " , url = . , auth_header ) %> %
463462 is_rate_limit_exceeded() %> %
463+ httr :: stop_for_status() %> %
464464 httr :: content() %> %
465465 purrr :: pluck(" tree" ) %> %
466466 magrittr :: extract2(which(purrr :: map_chr(. , " path" ) == forecaster_name ))
467467
468468 # Get the forecaster submission files.
469469 submission_file_pattern <- sprintf(" ^(20\\ d{2}-\\ d{2}-\\ d{2})-%s.csv$" , forecaster_name )
470470 submission_files <- forecaster_folder $ url %> %
471- httr :: GET( auth_header ) %> %
471+ RETRY( " GET " , url = . , auth_header ) %> %
472472 is_rate_limit_exceeded() %> %
473+ httr :: stop_for_status() %> %
473474 httr :: content() %> %
474475 purrr :: pluck(" tree" ) %> %
475476 purrr :: map_chr(" path" ) %> %
0 commit comments