Skip to content

Commit

Permalink
Compute cache path consistently (#574)
Browse files Browse the repository at this point in the history
Always do it in the board generation, not earlier. Fixes #529
  • Loading branch information
hadley authored Dec 9, 2021
1 parent 644ef53 commit c7af29f
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 43 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# pins (development version)

* Cache paths all computed in the same way, avoiding inconsistency and an
error when calling `board_register()` directly (#529).

* Drop add ins since they're not tested or documented (#525)

# pins 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion R/legacy_azure.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ board_register_azure <- function(name = "azure",
container = Sys.getenv("AZURE_STORAGE_CONTAINER"),
account = Sys.getenv("AZURE_STORAGE_ACCOUNT"),
key = Sys.getenv("AZURE_STORAGE_KEY"),
cache = board_cache_path(name),
cache = NULL,
path = NULL,
...) {
board <- legacy_azure(
Expand Down
4 changes: 2 additions & 2 deletions R/legacy_board_registry.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' @export
board_register <- function(board,
name = NULL,
cache = board_cache_path(name),
cache = NULL,
versions = NULL,
...) {
if (is_url(board)) {
Expand Down Expand Up @@ -50,7 +50,7 @@ board_register_rsconnect <- function(name = "rsconnect",
account = NULL,
key = NULL,
output_files = FALSE,
cache = board_cache_path(name),
cache = NULL,
...) {
board <- board_rsconnect(
name = name,
Expand Down
5 changes: 3 additions & 2 deletions R/legacy_datatxt.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#' @export
legacy_datatxt <- function(url,
headers = NULL,
cache = board_cache_path(name),
cache = NULL,
needs_index = TRUE,
browse_url = url,
index_updated = NULL,
Expand All @@ -40,6 +40,7 @@ legacy_datatxt <- function(url,

# use only subdomain as friendly name which is also used as cache folder
name <- name %||% gsub("https?://|\\..*", "", url)
cache <- cache %||% board_cache_path(name)

board <- new_board_v0("pins_board_datatxt",
name = name,
Expand All @@ -64,7 +65,7 @@ legacy_datatxt <- function(url,
board_register_datatxt <- function(url,
name = NULL,
headers = NULL,
cache = board_cache_path(name),
cache = NULL,
...) {
board <- legacy_datatxt(
name = name,
Expand Down
2 changes: 1 addition & 1 deletion R/legacy_dospaces.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ board_register_dospace <- function(name = "dospace",
key = Sys.getenv("DO_ACCESS_KEY_ID"),
secret = Sys.getenv("DO_SECRET_ACCESS_KEY"),
datacenter = Sys.getenv("DO_DATACENTER"),
cache = board_cache_path(name),
cache = NULL,
host = "digitaloceanspaces.com",
path = NULL,
...) {
Expand Down
2 changes: 1 addition & 1 deletion R/legacy_gcloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ legacy_gcloud <- function(
board_register_gcloud <- function(name = "gcloud",
bucket = Sys.getenv("GCLOUD_STORAGE_BUCKET"),
token = NULL,
cache = board_cache_path(name),
cache = NULL,
path = NULL,
...) {
board <- legacy_gcloud(
Expand Down
5 changes: 4 additions & 1 deletion R/legacy_github.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ legacy_github <- function(
path = "",
host = "https://api.github.com",
name = "github",
cache = NULL,
...) {

cache <- cache %||% board_cache_path(name)
token <- token %||% envvar_get("GITHUB_PAT") %||%
abort("Specify GitHub PAT with `token` or 'GITHUB_PAT' env var")

Expand All @@ -50,6 +52,7 @@ legacy_github <- function(
repo = repo,
path = if (!is.null(path) && nchar(path) > 0) paste0(path, "/") else "",
host = host,
cache = cache,
...
)

Expand Down Expand Up @@ -97,7 +100,7 @@ board_register_github <- function(name = "github",
token = NULL,
path = "",
host = "https://api.github.com",
cache = board_cache_path(name),
cache = NULL,
...) {
board <- legacy_github(
name = name,
Expand Down
5 changes: 4 additions & 1 deletion R/legacy_kaggle.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ legacy_kaggle <- function(token = NULL, name = "kaggle", ...) {
#' @export
board_register_kaggle <- function(name = "kaggle",
token = NULL,
cache = board_cache_path(name),
cache = NULL,
...) {

cache <- cache %||% board_cache_path(name)

board <- legacy_kaggle("kaggle",
name = name,
token = token,
Expand Down
4 changes: 1 addition & 3 deletions R/legacy_local.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ legacy_local <- function(path = NULL, name = "local", versions = FALSE) {

#' @rdname legacy_local
#' @export
board_register_local <- function(name = "local",
cache = board_cache_path(name),
...) {
board_register_local <- function(name = "local", cache = NULL, ...) {
board <- legacy_local(path = cache, name = name, ...)
board_register2(board)
}
Expand Down
2 changes: 1 addition & 1 deletion R/legacy_s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ board_register_s3 <- function(name = "s3",
bucket = Sys.getenv("AWS_BUCKET"),
key = Sys.getenv("AWS_ACCESS_KEY_ID"),
secret = Sys.getenv("AWS_SECRET_ACCESS_KEY"),
cache = board_cache_path(name),
cache = NULL,
host = "s3.amazonaws.com",
region = NULL,
path = NULL,
Expand Down
10 changes: 2 additions & 8 deletions man/board_register.Rd

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

2 changes: 1 addition & 1 deletion man/legacy_azure.Rd

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

10 changes: 2 additions & 8 deletions man/legacy_datatxt.Rd

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

2 changes: 1 addition & 1 deletion man/legacy_dospace.Rd

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

2 changes: 1 addition & 1 deletion man/legacy_gcloud.Rd

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

7 changes: 4 additions & 3 deletions man/legacy_github.Rd

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

7 changes: 1 addition & 6 deletions man/legacy_kaggle.Rd

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

2 changes: 1 addition & 1 deletion man/legacy_local.Rd

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

2 changes: 1 addition & 1 deletion man/legacy_s3.Rd

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

0 comments on commit c7af29f

Please sign in to comment.