-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replaced single-shot HTTP requests with RETRY logic #235
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,7 +258,7 @@ write_civis.character <- function(x, tablename, database = NULL, if_exists = "fa | |
credential_id = credential_id), | ||
import_args) | ||
job_r <- do.call(start_import_job, args) | ||
put_r <- httr::PUT(job_r[["uploadUri"]], body = httr::upload_file(x)) | ||
put_r <- httr::RETRY("PUT", job_r[["uploadUri"]], body = httr::upload_file(x), terminate_on = c(403, 404)) | ||
if (put_r$status_code != 200) { | ||
msg <- httr::content(put_r) | ||
stop(msg) | ||
|
@@ -562,9 +562,11 @@ download_civis.numeric <- function(x, file, | |
} | ||
|
||
args <- c(list(files_get(x)$fileUrl), | ||
list(httr::write_disk(file, overwrite = overwrite))) | ||
list(httr::write_disk(file, overwrite = overwrite)), | ||
verb = "GET", | ||
terminate_on = c(403, 404)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also please make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh sure, no problem! |
||
if (progress) args <- c(args, list(httr::progress())) | ||
resp <- do.call(httr::GET, args) | ||
resp <- do.call(httr::RETRY, args) | ||
|
||
httr::stop_for_status(resp, task = "download file from S3") | ||
invisible(file) | ||
|
@@ -902,14 +904,14 @@ download_script_results <- function(script_id, run_id, | |
stop_if_no_output(script_results) | ||
|
||
url <- script_results[["output"]][[1]][["path"]] | ||
args <- list(url) | ||
args <- list(url, verb = "GET", terminate_on = c(403, 404)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also please make this |
||
if (!is.null(filename)) { | ||
args <- c(args, list(httr::write_disk(filename, overwrite = TRUE))) | ||
} | ||
if (progress) { | ||
args <- c(args, list(httr::progress())) | ||
} | ||
r <- do.call(httr::GET, args) | ||
r <- do.call(httr::RETRY, args) | ||
httr::stop_for_status(r) | ||
r | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better to terminate on any 4xx error other 429 here (e.g.,
terminate_on = setdiff(400:499, 429)
). That's what AWS recommends here, and this URI and the one forwrite_disk
below will be S3 URLs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure I can do that!
setdiff()
is a super clean way to express it, I like it 😀There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed the comments in 7cdb800