Skip to content

Commit

Permalink
Reduce needed packages
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 19, 2021
1 parent efb115e commit 7cde6e7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 56 deletions.
10 changes: 2 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Depends:
R (>= 3.2.0)
Imports:
arrow,
base64enc,
crayon,
digest,
filelock,
Expand All @@ -44,20 +43,15 @@ Imports:
yaml,
zip
Suggests:
callr,
covr,
data.table,
datasets,
data.table,
knitr,
R.utils,
R6,
rmarkdown,
rsconnect,
shiny,
stringi,
testthat (>= 3.0.0),
tibble,
xml2
tibble
VignetteBuilder:
knitr
Config/testthat/edition: 3
Expand Down
4 changes: 2 additions & 2 deletions R/board_azure.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ azure_headers <- function(board, verb, path, file) {
sep = "\n"
)

signature <- openssl::sha256(charToRaw(content), key = base64enc::base64decode(board$key)) %>%
base64enc::base64encode()
signature <- openssl::sha256(charToRaw(content), key = jsonlite::base64_dec(board$key)) %>%
jsonlite::base64_enc()

headers <- httr::add_headers(
`x-ms-date` = date,
Expand Down
2 changes: 1 addition & 1 deletion R/board_dospaces.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dospace_headers <- function(board, verb, path, file) {
)

signature <- openssl::sha1(charToRaw(content), key = board$secret) %>%
base64enc::base64encode()
jsonlite::base64_enc()

headers <- httr::add_headers(
Host = paste0(space, ".", board$datacenter, ".", board$host),
Expand Down
10 changes: 5 additions & 5 deletions R/board_github.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ github_update_temp_index <- function(board, path, commit, operation, name = NULL

# API returns contents when size < 1mb
if (!is.null(content$content)) {
index <- board_manifest_load(rawToChar(base64enc::base64decode(content$content)))
index <- board_manifest_load(rawToChar(jsonlite::base64_dec(content$content)))
}
else {
response <- httr::GET(content$download_url, github_headers(board))
Expand Down Expand Up @@ -169,7 +169,7 @@ github_update_index <- function(board, path, commit, operation, name = NULL, met

file_url <- github_url(board, branch = branch, "/contents/", board$path, "data.txt")

base64 <- base64enc::base64encode(index_file)
base64 <- jsonlite::base64_enc(index_file)
response <- httr::PUT(file_url,
body = list(
message = commit,
Expand Down Expand Up @@ -257,7 +257,7 @@ github_upload_content <- function(board, name, file, file_path, commit, sha, bra
file_url <- github_url(board, branch = branch, "/contents/", board$path, name, "/", file)
pin_log("uploading ", file_url)

base64 <- base64enc::base64encode(file_path)
base64 <- jsonlite::base64_enc(file_path)
response <- httr::PUT(file_url,
body = list(
message = commit,
Expand All @@ -280,7 +280,7 @@ github_upload_blob <- function(board, file, file_path, commit) {
blob_url <- github_url(board, branch = NULL, "/git/blobs")
pin_log("uploading ", file)

base64 <- base64enc::base64encode(file_path)
base64 <- jsonlite::base64_enc(file_path)
response <- httr::POST(blob_url,
body = list(
content = base64,
Expand Down Expand Up @@ -502,7 +502,7 @@ board_pin_find.pins_board_github <- function(board, text, ...) {
content <- httr::content(result, encoding = "UTF-8")
}
else {
content <- rawToChar(base64enc::base64decode(content$content))
content <- rawToChar(jsonlite::base64_dec(content$content))
}

result <- board_manifest_load(content) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/board_s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ s3_headers <- function(board, verb, path, file) {
)

signature <- openssl::sha1(charToRaw(content), key = board$secret) %>%
base64enc::base64encode()
jsonlite::base64_enc()

headers <- httr::add_headers(
Host = paste0(bucket, ".", board$host),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-board-azure.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("board contains proper azure headers", {
mock_board <- list(key = base64enc::base64encode(as.raw(1:3)), url = "https://foo.com")
mock_board <- list(key = jsonlite::base64_enc(as.raw(1:3)), url = "https://foo.com")
headers <- names(azure_headers(mock_board, "PUT", "x", "files/hello.txt")$headers)

expect_true("x-ms-date" %in% headers)
Expand Down
38 changes: 0 additions & 38 deletions tests/testthat/test-pin_registry.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,3 @@ test_that("can access entries", {
pin_registry_update(board, "x", list(test = "x"))
expect_equal(pin_registry_retrieve(board, "x"), list(test = "x", name = "x"))
})

test_that("can pin() concurrently", {
# BEWARE: this tests the INSTALLED versions of pins
skip_on_ci()
# This fails on CI in a way that I can not replicate locally, even when I
# make n_proc and n_pins substantially larger. I've skipped it because
# I don't think multi-process race conditions are likely to be a problem
# in real-life.

temp_path <- withr::local_tempdir()
board <- board_folder(temp_path)

n_proc <- 10
n_pins <- 10

pin_n <- function(path, proc, n_pins) {
board <- pins::board_folder(path)
data <- list(message = "concurrent test")
for (i in seq_len(n_pins)) {
pins::pin(data, name = as.character(proc * 100 + i), board = board)
}
}

processes <- list()
for (i in seq_len(n_proc)) {
processes[[i]] <- callr::r_bg(pin_n, list(
path = temp_path,
proc = i,
n_pins = n_pins
))
}
for (i in seq_len(n_proc)) {
processes[[i]]$wait()
}

index <- pin_registry_read(board)
expect_equal(length(index), n_proc * n_pins)
})

0 comments on commit 7cde6e7

Please sign in to comment.