From 24d69a9a6c3b1eaf010991d9930ec84d13252cbd Mon Sep 17 00:00:00 2001 From: Fran Barton Date: Mon, 23 Feb 2026 22:34:22 +0000 Subject: [PATCH 1/5] Allow `read_azure_rds` to pass through a compression type argument Should close #85 --- R/read_azure_files.R | 19 ++++++++++++++----- man/read_azure_rds.Rd | 10 ++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/R/read_azure_files.R b/R/read_azure_files.R index b174e0d..e76183b 100644 --- a/R/read_azure_files.R +++ b/R/read_azure_files.R @@ -53,7 +53,7 @@ read_azure_json <- function(container, file, path = "/", info = NULL, ...) { #' #' @inheritParams read_azure_parquet #' @param ... optional arguments to be passed through to -#' [yyjsonr::read_json_file] +#' [yyjsonr::read_json_file] #' @returns A list #' @export read_azure_jsongz <- function(container, file, path = "/", info = NULL, ...) { @@ -70,11 +70,20 @@ read_azure_jsongz <- function(container, file, path = "/", info = NULL, ...) { #' Read an rds file from Azure storage #' #' @inheritParams read_azure_parquet -#' @returns Data object that was stored in the rds file +#' @param ... optional arguments to be passed through to +#' [AzureStor::storage_load_rds]. For example, a compression type (one of +#' c("unknown", "gzip", "bzip2", "xz", "zstd", "none")) can be provided using +#' the argument `type`, which will be passed on to [memDecompress] via +#' [AzureStor::storage_load_rds]. +# If nothing is provided here, the compression type will be set to "none". +#' @returns The data object that was stored in the rds file #' @export -read_azure_rds <- function(container, file, path = "/", info = NULL) { - check_blob_exists(container, file, "rds", info, path) |> - AzureStor::storage_load_rds(container, file = _) +read_azure_rds <- function(container, file, path = "/", info = NULL, ...) { + # If the user doesn't specify a (de)compression type with `type` in `...`, we + # will set a `type` of "none", as this seems to be the standard on SU Azure + dots <- rlang::dots_list(..., type = "none", .homonyms = "first") + blob <- check_blob_exists(container, file, "rds", info, path) + rlang::inject(AzureStor::storage_load_rds(container, blob, !!!dots)) } diff --git a/man/read_azure_rds.Rd b/man/read_azure_rds.Rd index c099418..8f3e0e4 100644 --- a/man/read_azure_rds.Rd +++ b/man/read_azure_rds.Rd @@ -4,7 +4,7 @@ \alias{read_azure_rds} \title{Read an rds file from Azure storage} \usage{ -read_azure_rds(container, file, path = "/", info = NULL) +read_azure_rds(container, file, path = "/", info = NULL, ...) } \arguments{ \item{container}{An Azure container object, as returned by \link{get_container}} @@ -25,9 +25,15 @@ being read. Useful for checking the function is doing what is expected, but can be turned off with \code{FALSE}. Can be set persistently with the option "azkit.info". If \code{NULL} then it will default to the value of \link[rlang:is_interactive]{rlang::is_interactive} (that is, \code{TRUE} for interactive sessions).} + +\item{...}{optional arguments to be passed through to +\link[AzureStor:storage_save]{AzureStor::storage_load_rds}. For example, a compression type (one of +c("unknown", "gzip", "bzip2", "xz", "zstd", "none")) can be provided using +the argument \code{type}, which will be passed on to \link{memDecompress} via +\link[AzureStor:storage_save]{AzureStor::storage_load_rds}.} } \value{ -Data object that was stored in the rds file +The data object that was stored in the rds file } \description{ Read an rds file from Azure storage From 642dfacf5fea6bae10a30b2da31c103b5477d1e2 Mon Sep 17 00:00:00 2001 From: Fran Barton Date: Mon, 23 Feb 2026 22:35:02 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=94=89=20Improve=20error=20messaging?= =?UTF-8?q?=20in=20`get=5Fcontainer`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/get_container.R | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/R/get_container.R b/R/get_container.R index 4bbd257..31a5d3d 100644 --- a/R/get_container.R +++ b/R/get_container.R @@ -21,12 +21,18 @@ get_container <- function( endpoint_url = NULL, ... ) { - msg <- paste0( + msg1 <- paste0( "{.var container_name} is empty. ", "Did you forget to set an environment variable?" ) + msg2 <- paste0( + "{.var endpoint_url} is empty. ", + "Did you forget to set an environment variable?" + ) container_name <- (container_name %||% check_envvar("AZ_CONTAINER")) |> - check_nzchar(msg) + check_nzchar(msg1) + endpoint_url <- (endpoint_url %||% check_envvar("AZ_STORAGE_EP")) |> + check_nzchar(msg2) token <- token %||% get_auth_token(...) get_azure_endpoint(token, endpoint_url) |> From a4e4194562fad2209cf7be961ea88e1c0c5b7da5 Mon Sep 17 00:00:00 2001 From: Fran Barton Date: Mon, 23 Feb 2026 22:32:31 +0000 Subject: [PATCH 3/5] Export check_* functions Should close #84 --- NAMESPACE | 3 +++ R/{azkit_helpers.R => helpers.R} | 6 +++--- man/check_container_class.Rd | 2 +- man/check_nzchar.Rd | 3 +-- man/check_scalar_type.Rd | 3 +-- man/check_that.Rd | 2 +- man/check_vec.Rd | 3 +-- man/gregg.Rd | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) rename R/{azkit_helpers.R => helpers.R} (98%) diff --git a/NAMESPACE b/NAMESPACE index 3f80daa..ca9071c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,7 +2,10 @@ export(check_container_class) export(check_envvar) +export(check_nzchar) +export(check_scalar_type) export(check_that) +export(check_vec) export(generate_resource) export(get_auth_token) export(get_container) diff --git a/R/azkit_helpers.R b/R/helpers.R similarity index 98% rename from R/azkit_helpers.R rename to R/helpers.R index 550bca7..c5d5b88 100644 --- a/R/azkit_helpers.R +++ b/R/helpers.R @@ -46,7 +46,7 @@ ct_error_msg <- \(text) paste0("{.fn check_that}: ", text) #' predicate. "some" is unlikely to be useful often, but it is available. #' @inheritParams check_that #' @seealso [check_scalar_type()] -#' @keywords internal +#' @export check_vec <- function( x, predicate, @@ -78,7 +78,7 @@ cv_error_msg <- \(text) paste0("{.fn check_vec}: ", text) #' @seealso [check_that] #' @inheritParams check_that #' @param type A string defining the R object type that `x` is checked to be -#' @keywords internal +#' @export check_scalar_type <- function( x, type, @@ -122,7 +122,7 @@ cst_error_msg <- \(text) paste0("{.fn check_scalar_type}: ", text) #' semantic markup. Variable values will be searched for in the environment of #' the caller function (not in the environment of `check_nzchar()`). This #' makes it easier to include informative values in the message. -#' @keywords internal +#' @export check_nzchar <- function(x, message, pf = parent.frame()) { if (is.null(x)) { NULL diff --git a/man/check_container_class.Rd b/man/check_container_class.Rd index 1d3c3ec..9d581a0 100644 --- a/man/check_container_class.Rd +++ b/man/check_container_class.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/azkit_helpers.R +% Please edit documentation in R/helpers.R \name{check_container_class} \alias{check_container_class} \title{Check that a container looks like a real container} diff --git a/man/check_nzchar.Rd b/man/check_nzchar.Rd index 72ae9b6..25deed0 100644 --- a/man/check_nzchar.Rd +++ b/man/check_nzchar.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/azkit_helpers.R +% Please edit documentation in R/helpers.R \name{check_nzchar} \alias{check_nzchar} \title{Check if a supplied non-NULL value is a string with >0 characters} @@ -22,4 +22,3 @@ be used in the custom error message.} Will error if x is equal to \code{""}, or if it is otherwise missing or invalid. With the exception that if x is NULL, then NULL will be passed through. } -\keyword{internal} diff --git a/man/check_scalar_type.Rd b/man/check_scalar_type.Rd index 7b44f15..9bd9172 100644 --- a/man/check_scalar_type.Rd +++ b/man/check_scalar_type.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/azkit_helpers.R +% Please edit documentation in R/helpers.R \name{check_scalar_type} \alias{check_scalar_type} \title{An alternative to stopifnot/assert_that etc} @@ -28,4 +28,3 @@ Possible values for the \code{type} parameter are: "character", "logical", "list \seealso{ \link{check_that} } -\keyword{internal} diff --git a/man/check_that.Rd b/man/check_that.Rd index 9140faf..64ba285 100644 --- a/man/check_that.Rd +++ b/man/check_that.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/azkit_helpers.R +% Please edit documentation in R/helpers.R \name{check_that} \alias{check_that} \title{An alternative to stopifnot/assert_that etc} diff --git a/man/check_vec.Rd b/man/check_vec.Rd index 4663939..5d79e03 100644 --- a/man/check_vec.Rd +++ b/man/check_vec.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/azkit_helpers.R +% Please edit documentation in R/helpers.R \name{check_vec} \alias{check_vec} \title{An alternative to stopifnot/assert_that etc} @@ -43,4 +43,3 @@ element-wise, so will potentially return \code{TRUE} even if \code{length(x) > 1 \seealso{ \code{\link[=check_scalar_type]{check_scalar_type()}} } -\keyword{internal} diff --git a/man/gregg.Rd b/man/gregg.Rd index 53288ab..d2a375a 100644 --- a/man/gregg.Rd +++ b/man/gregg.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/azkit_helpers.R +% Please edit documentation in R/helpers.R \name{gregg} \alias{gregg} \title{grepl a glued regex} From 0f1f02b766e3faf062bcded19caa5778e811606d Mon Sep 17 00:00:00 2001 From: Fran Barton Date: Tue, 24 Feb 2026 00:25:09 +0000 Subject: [PATCH 4/5] Set tenant to "common" in `get_auth_token()` Should close #83 --- DESCRIPTION | 2 +- R/get_auth_token.R | 4 ++-- man/get_auth_token.Rd | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0d9dc71..fa4ed41 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: azkit Title: Azure storage authentication toolkit -Version: 0.2.3 +Version: 0.2.4 Authors@R: c(person( "Fran", "Barton", diff --git a/R/get_auth_token.R b/R/get_auth_token.R index e493df6..9e8a0b8 100644 --- a/R/get_auth_token.R +++ b/R/get_auth_token.R @@ -24,7 +24,7 @@ #' If setting version to 2, ensure that the `aad_version` argument is also set #' to 2. Both are set to use AAD version 1 by default. #' @param tenant A string specifying the Azure tenant. Defaults to -#' `"organizations"`. See [AzureAuth::get_azure_token] for other values. +#' `"common"`. See [AzureAuth::get_azure_token] for other values. #' @param client_id A string specifying the application ID (client ID). If #' `NULL`, (the default) the function attempts to obtain the client ID from the #' Azure Resource Manager token, or prompts the user to log in to obtain it. @@ -62,7 +62,7 @@ #' @export get_auth_token <- function( resource = generate_resource(), - tenant = "organizations", + tenant = "common", client_id = NULL, auth_method = "authorization_code", aad_version = 1, diff --git a/man/get_auth_token.Rd b/man/get_auth_token.Rd index af708df..a966358 100644 --- a/man/get_auth_token.Rd +++ b/man/get_auth_token.Rd @@ -6,7 +6,7 @@ \usage{ get_auth_token( resource = generate_resource(), - tenant = "organizations", + tenant = "common", client_id = NULL, auth_method = "authorization_code", aad_version = 1, @@ -25,7 +25,7 @@ If setting version to 2, ensure that the \code{aad_version} argument is also set to 2. Both are set to use AAD version 1 by default.} \item{tenant}{A string specifying the Azure tenant. Defaults to -\code{"organizations"}. See \link[AzureAuth:get_azure_token]{AzureAuth::get_azure_token} for other values.} +\code{"common"}. See \link[AzureAuth:get_azure_token]{AzureAuth::get_azure_token} for other values.} \item{client_id}{A string specifying the application ID (client ID). If \code{NULL}, (the default) the function attempts to obtain the client ID from the From f9b01fe2a09f02468126d4a588dc3329d92b18b9 Mon Sep 17 00:00:00 2001 From: Fran Barton Date: Tue, 24 Feb 2026 12:31:19 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=9A=A2=20Export=20error=20message=20f?= =?UTF-8?q?unctions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NAMESPACE | 3 +++ R/helpers.R | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index ca9071c..a7b10dc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,9 @@ export(check_nzchar) export(check_scalar_type) export(check_that) export(check_vec) +export(cst_error_msg) +export(ct_error_msg) +export(cv_error_msg) export(generate_resource) export(get_auth_token) export(get_container) diff --git a/R/helpers.R b/R/helpers.R index c5d5b88..18afcd0 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -21,7 +21,7 @@ check_that <- function(x, predicate, message, pf = parent.frame()) { } -#' @keywords internal +#' @export ct_error_msg <- \(text) paste0("{.fn check_that}: ", text) #' An alternative to stopifnot/assert_that etc @@ -63,7 +63,7 @@ check_vec <- function( } } -#' @keywords internal +#' @export cv_error_msg <- \(text) paste0("{.fn check_vec}: ", text) @@ -108,7 +108,7 @@ check_scalar_type <- function( } } -#' @keywords internal +#' @export cst_error_msg <- \(text) paste0("{.fn check_scalar_type}: ", text)