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
9 changes: 5 additions & 4 deletions R/board.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ board_cache_path <- function(name) {
# R_CONFIG_ACTIVE suggests we're in a production environment
if (has_envvars("R_CONFIG_ACTIVE") || has_envvars("PINS_USE_CACHE")) {
path <- fs::dir_create(tempdir(), "pins")
} else if (has_envvars("PINS_CACHE_DIR") ) {
} else if (has_envvars("PINS_CACHE_DIR")) {
path <- Sys.getenv("PINS_CACHE_DIR")
} else {
path <- cache_dir()
Expand Down Expand Up @@ -208,7 +208,9 @@ board_deparse.pins_board <- function(board, ...) {
write_board_manifest <- function(board, ...) {
manifest <- make_manifest(board)
write_board_manifest_yaml(board, manifest, ...)
pins_inform("Manifest file written to root folder of board, as `{manifest_pin_yaml_filename}`")
pins_inform(
"Manifest file written to root folder of board, as `{manifest_pin_yaml_filename}`"
)
invisible(board)
}

Expand All @@ -223,7 +225,7 @@ make_manifest <- function(board) {

result <- map(
pin_names,
~fs::path(.x, pin_versions(board, name = .x)$version) |>
~ fs::path(.x, pin_versions(board, name = .x)$version) |>
end_with_slash() |> # versions usually don't include slash
as.list()
)
Expand Down Expand Up @@ -267,4 +269,3 @@ board_empty_results <- function() {
class = character()
)
}

56 changes: 44 additions & 12 deletions R/board_azure.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@
#' board |> pin_list()
#' board |> pin_read("iris")
#' }
board_azure <- function(container, path = "", n_processes = 10, versioned = TRUE, cache = NULL) {
board_azure <- function(
container,
path = "",
n_processes = 10,
versioned = TRUE,
cache = NULL
) {
check_installed("AzureStor")

if (path == "/") {
Expand All @@ -66,7 +72,10 @@ board_azure <- function(container, path = "", n_processes = 10, versioned = TRUE
cache <- cache %||% board_cache_path(paste0("azure-", hash(board_path)))
if (path != "") {
if (inherits(container, "file_share")) {
try(AzureStor::create_storage_dir(container, path, recursive = TRUE), silent = TRUE)
try(
AzureStor::create_storage_dir(container, path, recursive = TRUE),
silent = TRUE
)
} else {
AzureStor::create_storage_dir(container, path)
}
Expand All @@ -88,8 +97,11 @@ board_azure_test <- function(path, type = c("blob", "file", "dfs"), ...) {

type <- arg_match(type)
acct_name <- Sys.getenv("PINS_AZURE_ACCOUNT")
acct_url <- sprintf("https://%s.%s.core.windows.net/pins-rstats-testing-ci",
acct_name, type)
acct_url <- sprintf(
"https://%s.%s.core.windows.net/pins-rstats-testing-ci",
acct_name,
type
)

container <- AzureStor::storage_container(
acct_url,
Expand Down Expand Up @@ -135,7 +147,9 @@ pin_meta.pins_board_azure <- function(board, name, version = NULL, ...) {
metadata_blob <- fs::path(name, version, "data.txt")

metadata_absolute_path <- azure_normalize_path(board, metadata_blob)
if (!AzureStor::storage_file_exists(board$container, metadata_absolute_path)) {
if (
!AzureStor::storage_file_exists(board$container, metadata_absolute_path)
) {
abort_pin_version_missing(version)
}
path_version <- fs::path(board$cache, name, version)
Expand All @@ -162,10 +176,21 @@ pin_fetch.pins_board_azure <- function(board, name, version = NULL, ...) {
}

#' @export
pin_store.pins_board_azure <- function(board, name, paths, metadata,
versioned = NULL, ...) {
pin_store.pins_board_azure <- function(
board,
name,
paths,
metadata,
versioned = NULL,
...
) {
check_pin_name(name)
version <- version_setup(board, name, version_name(metadata), versioned = versioned)
version <- version_setup(
board,
name,
version_name(metadata),
versioned = versioned
)

version_dir <- azure_normalize_path(board, name, version)

Expand Down Expand Up @@ -203,7 +228,6 @@ board_deparse.pins_board_azure <- function(board, ...) {

#' @export
write_board_manifest_yaml.pins_board_azure <- function(board, manifest, ...) {

paths <- AzureStor::list_storage_files(board$container, info = "name")

if (manifest_pin_yaml_filename %in% paths) {
Expand Down Expand Up @@ -254,8 +278,14 @@ azure_dir_exists <- function(board, path) {
AzureStor::storage_dir_exists(board$container, dir)
}

local_azure_progress <- function(progress = is_interactive(), env = parent.frame()) {
withr::local_options(list(azure_storage_progress_bar = progress), .local_envir = env)
local_azure_progress <- function(
progress = is_interactive(),
env = parent.frame()
) {
withr::local_options(
list(azure_storage_progress_bar = progress),
.local_envir = env
)
}

azure_download <- function(board, keys, progress = is_interactive()) {
Expand All @@ -266,7 +296,9 @@ azure_download <- function(board, keys, progress = is_interactive()) {
needed <- !fs::file_exists(paths)
if (any(needed)) {
AzureStor::storage_multidownload(
board$container, keys[needed], paths[needed],
board$container,
keys[needed],
paths[needed],
max_concurrent_transfers = board$n_processes
)
fs::file_chmod(paths[needed], "u=r")
Expand Down
Loading
Loading