amoeba commented on code in PR #35398:
URL: https://github.com/apache/arrow/pull/35398#discussion_r1184380653
##########
r/R/filesystem.R:
##########
@@ -442,6 +442,57 @@ default_s3_options <- list(
request_timeout = -1
)
+# Enumerate possible values for AWS SDK log levels, used by s3_init
+s3_log_levels <- c("off", "fatal", "error", "warn", "info", "debug", "trace")
+
+#' Initialize S3
+#'
+#' Must be called before other S3 functions such as \link{s3_bucket}.
+#'
+#' @param log_level string for log level to set. See details.
+#' @param num_event_loop_threads How many threads to use for the AWS SDK's I/O
+#' event loop. Defaults to 1.
+#' @details The parameter `log_level` must be one of: off, fatal, error, warn,
+#' info, debug, or trace and is case insensitive.
+#'
+#' @examples
+#' # Initialize S3 with Debug-level logging
+#' \dontrun{
+#' s3_init("debug")
+#' }
+s3_init <- function(log_level, num_event_loop_threads = 1) {
+ stopifnot(is.character(log_level))
+ stopifnot(is.numeric(num_event_loop_threads))
+
+ log_level_normalized <- tolower(log_level)
+
+ # Validate log_level
+ if (!(log_level_normalized %in% s3_log_levels)) {
+ stop(
+ "Argument 'log_level' must be one of: ",
+ paste(
+ paste(s3_log_levels[seq_len(length(s3_log_levels) - 1)], collapse = ",
"),
+ s3_log_levels[length(s3_log_levels)],
+ sep = ", or "),
+ paste0(" but was '", log_level_normalized, "'."),
+ call. = FALSE)
+ return(invisible())
+ }
+
+ # Validate num_event_loop_threads
+ if (num_event_loop_threads < 1) {
+ stop(
+ "Argument 'num_event_loop_threads' should be a positive integer ",
+ "greater than or equal to 1 but was '", num_event_loop_threads, "'.",
+ call. = FALSE
+ )
+
+ return(invisible())
Review Comment:
Now that I look at it with fresh eyes, that's pretty silly of me. No need
for it. Good catch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]