Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions R/get_container.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) |>
Expand Down
6 changes: 3 additions & 3 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,7 +63,7 @@ check_vec <- function(
}
}

#' @keywords internal
#' @export
cv_error_msg <- \(text) paste0("{.fn check_vec}: ", text)


Expand Down Expand Up @@ -108,7 +108,7 @@ check_scalar_type <- function(
}
}

#' @keywords internal
#' @export
cst_error_msg <- \(text) paste0("{.fn check_scalar_type}: ", text)


Expand Down
19 changes: 14 additions & 5 deletions R/read_azure_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) {
Expand All @@ -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))
}


Expand Down
10 changes: 8 additions & 2 deletions man/read_azure_rds.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading