diff --git a/.github/workflows/check-boards.yaml b/.github/workflows/check-boards.yaml index 6dc7a086..b815ad9d 100644 --- a/.github/workflows/check-boards.yaml +++ b/.github/workflows/check-boards.yaml @@ -15,7 +15,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes - # needed for modern board tests + # board specific env vars PINS_AZURE_SAS: ${{ secrets.PINS_AZURE_SAS }} PINS_AZURE_KEY: ${{ secrets.PINS_AZURE_KEY }} PINS_AZURE_ACCOUNT: ${{ secrets.PINS_AZURE_ACCOUNT }} @@ -26,12 +26,6 @@ jobs: DATABRICKS_HOST: "https://rstudio-partner-posit-default.cloud.databricks.com" PINS_DATABRICKS_FOLDER_URL: "/Volumes/workshops/models/vetiver" - # needed for legacy board tests - TEST_AWS_BUCKET: "pins-github-tests" - TEST_AWS_KEY: "AKIAWDFKE5M2ZHDUORMW" - TEST_AWS_REGION: "us-east-2" - TEST_AWS_SECRET: ${{ secrets.TEST_AWS_SECRET }} - steps: - uses: actions/checkout@v3 diff --git a/DESCRIPTION b/DESCRIPTION index 9a1aca3e..cb22e6e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Type: Package Package: pins -Title: Pin, Discover and Share Resources +Title: Pin, Discover, and Share Resources Version: 1.3.0.9000 Authors@R: c( person("Julia", "Silge", , "julia.silge@posit.co", role = c("cre", "aut"), @@ -13,8 +13,8 @@ Authors@R: c( Description: Publish data sets, models, and other R objects, making it easy to share them across projects and with your colleagues. You can pin objects to a variety of "boards", including local folders (to - share on a networked drive or with 'DropBox'), 'RStudio' connect, - Amazon S3, and more. + share on a networked drive or with 'DropBox'), 'Posit Connect', + 'AWS S3', and more. License: Apache License (>= 2) URL: https://pins.rstudio.com/, https://github.com/rstudio/pins-r BugReports: https://github.com/rstudio/pins-r/issues @@ -73,4 +73,4 @@ Config/Needs/website: tidyverse/tidytemplate Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index 7173a25c..0e5706bf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -77,6 +77,10 @@ S3method(pin_exists,pins_board_kaggle_dataset) S3method(pin_exists,pins_board_ms365) S3method(pin_exists,pins_board_s3) S3method(pin_exists,pins_board_url) +S3method(pin_extract,"compressed-tar") +S3method(pin_extract,default) +S3method(pin_extract,gzip) +S3method(pin_extract,zip) S3method(pin_fetch,pins_board_azure) S3method(pin_fetch,pins_board_connect) S3method(pin_fetch,pins_board_databricks) diff --git a/NEWS.md b/NEWS.md index 0a755237..fb7c4bb9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * Changed the function signature of `pin_upload()` to be consistent with `pin_write()` i.e. arguments like `tags` must be passed by name and not position (#809). +* Started gradual deprecation process for legacy pins functions such as `pin()` (#844). + ## Other improvements * Added example Python code to pin previews for Posit Connect (#806). diff --git a/R/board_connect.R b/R/board_connect.R index 42a1d4b3..cc933fbd 100644 --- a/R/board_connect.R +++ b/R/board_connect.R @@ -26,7 +26,7 @@ #' #' ```r #' board <- board_url(c( -#' numbers = "https://colorado.posit.co/rsc/great-numbers/" +#' numbers = "https://pub.current.posit.team/public/great-numbers/" #' )) #' board %>% pin_read("numbers") #' ``` @@ -701,24 +701,24 @@ rsc_v1 <- function(...) { # Testing setup ----------------------------------------------------------- board_connect_test <- function(...) { - if (connect_has_colorado()) { - board_connect_colorado(...) + if (connect_has_ptd()) { + board_connect_ptd(...) } else { board_connect_susan(...) } } -# Use Colorado for local testing -connect_has_colorado <- function() { +# Use demo.posit.team PTD for local testing +connect_has_ptd <- function() { accounts <- rsconnect::accounts() - "colorado.posit.co" %in% accounts$server + "pub.demo.posit.team" %in% accounts$server } -board_connect_colorado <- function(...) { - if (!connect_has_colorado()) { - testthat::skip("board_connect_colorado() only works with Posit's demo server") +board_connect_ptd <- function(...) { + if (!connect_has_ptd()) { + testthat::skip("board_connect_ptd() only works with Posit's demo PTD server") } - board_connect(..., server = "colorado.posit.co", auth = "rsconnect", cache = fs::file_temp()) + board_connect(..., server = "pub.demo.posit.team", auth = "rsconnect", cache = fs::file_temp()) } board_connect_susan <- function(...) { diff --git a/R/board_connect_url.R b/R/board_connect_url.R index cc67395c..c4ec0cf6 100644 --- a/R/board_connect_url.R +++ b/R/board_connect_url.R @@ -22,7 +22,7 @@ #' connect_auth_headers() #' #' board <- board_connect_url(c( -#' my_vanity_url_pin = "https://colorado.posit.co/rsc/great-numbers/" +#' my_vanity_url_pin = "https://pub.current.posit.team/public/great-numbers/" #' )) #' #' board %>% pin_read("my_vanity_url_pin") @@ -68,16 +68,16 @@ vanity_url_test <- function(env = parent.frame()) { } board_connect_url_test <- function(...) { - if (connect_has_colorado()) { - board_connect_url_colorado(...) + if (connect_has_ptd()) { + board_connect_url_ptd(...) } else { board_connect_url_susan(...) } } -board_connect_url_colorado <- function(...) { - if (!connect_has_colorado()) { - testthat::skip("board_connect_url_colorado() only works with Posit's demo server") +board_connect_url_ptd <- function(...) { + if (!connect_has_ptd()) { + testthat::skip("board_connect_url_ptd() only works with Posit's demo server") } board_connect_url(..., cache = fs::file_temp()) } diff --git a/R/legacy_azure.R b/R/legacy_azure.R index 571c519a..92ec2105 100644 --- a/R/legacy_azure.R +++ b/R/legacy_azure.R @@ -1,6 +1,8 @@ #' Azure board (legacy API) #' #' @description +#' `r lifecycle::badge('deprecated')` +#' #' To use Microsoft Azure Storage as a board, you'll need an Azure Storage #' account, an Azure Storage container, and an Azure Storage key. #' You can sign-up and create those at [portal.azure.com](https://portal.azure.com). @@ -24,6 +26,7 @@ #' ) #' } #' @export +#' @keywords internal legacy_azure <- function( container = Sys.getenv("AZURE_STORAGE_CONTAINER"), account = Sys.getenv("AZURE_STORAGE_ACCOUNT"), @@ -61,6 +64,12 @@ board_register_azure <- function(name = "azure", cache = NULL, path = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_azure()", + details = 'Learn more at ' + ) + board <- legacy_azure( name = name, container = container, diff --git a/R/legacy_board.R b/R/legacy_board.R index 033a3d06..f87141fc 100644 --- a/R/legacy_board.R +++ b/R/legacy_board.R @@ -1,6 +1,8 @@ #' Custom Boards #' +#' `r lifecycle::badge('deprecated')` +#' #' Family of functions meant to be used to implement custom boards extensions, #' not to be used by users. #' diff --git a/R/legacy_board_registry.R b/R/legacy_board_registry.R index 7ff007be..3ac0a602 100644 --- a/R/legacy_board_registry.R +++ b/R/legacy_board_registry.R @@ -1,6 +1,8 @@ #' Board registry (legacy API) #' #' @description +#' `r lifecycle::badge('deprecated')` +#' #' The legacy pins API uses a board registry, where you first register a board #' then refer to it by name in calls to pin functions. #' @@ -52,6 +54,12 @@ board_register_rsconnect <- function(name = "rsconnect", output_files = FALSE, cache = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_rsconnect()", + details = 'Learn more at ' + ) + board <- board_rsconnect( name = name, server = server, diff --git a/R/legacy_datatxt.R b/R/legacy_datatxt.R index 1bac9361..ef04b960 100644 --- a/R/legacy_datatxt.R +++ b/R/legacy_datatxt.R @@ -1,5 +1,7 @@ #' Remote "data.txt" board (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' Use board that for a website that uses the [data.txt](https://datatxt.org) #' specification. A `data.txt` file is a YAML that provides some basic metadata #' about a directory of files. @@ -26,6 +28,7 @@ #' # find pins #' pin_find(board = "txtexample") #' @export +#' @keywords internal legacy_datatxt <- function(url, headers = NULL, cache = NULL, @@ -67,6 +70,12 @@ board_register_datatxt <- function(url, headers = NULL, cache = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_datatxt()", + details = 'Learn more at ' + ) + board <- legacy_datatxt( name = name, url = url, diff --git a/R/legacy_dospaces.R b/R/legacy_dospaces.R index 164b7d86..b3bb7dfd 100644 --- a/R/legacy_dospaces.R +++ b/R/legacy_dospaces.R @@ -1,5 +1,7 @@ #' DigitalOcean board (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' To use DigitalOcean Spaces as a board, you first #' need an DigitalOcean space and a storage key. You can sign-up and create #' those at [digitalocean.com](https://www.digitalocean.com/). @@ -21,6 +23,7 @@ #' board <- legacy_dospace(bucket = "s3bucket") #' } #' @export +#' @keywords internal legacy_dospace <- function( space = Sys.getenv("DO_SPACE"), key = Sys.getenv("DO_ACCESS_KEY_ID"), @@ -64,6 +67,12 @@ board_register_dospace <- function(name = "dospace", host = "digitaloceanspaces.com", path = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_dospace()", + details = 'Learn more at ' + ) + board <- legacy_dospace( name = name, space = space, diff --git a/R/legacy_gcloud.R b/R/legacy_gcloud.R index ea827477..6b731d45 100644 --- a/R/legacy_gcloud.R +++ b/R/legacy_gcloud.R @@ -1,5 +1,7 @@ #' Google Cloud board (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' To use a Google Cloud Storage board, you first need a Google Cloud Storage #' account, a Google Storage bucket, and an access token or the #' [Google Cloud SDK](https://cloud.google.com/sdk/) properly installed and @@ -22,6 +24,7 @@ #' board <- legacy_gcloud(container = "gcloudcontainer") #' } #' @export +#' @keywords internal legacy_gcloud <- function( bucket = Sys.getenv("GCLOUD_STORAGE_BUCKET"), token = NULL, @@ -68,6 +71,12 @@ board_register_gcloud <- function(name = "gcloud", cache = NULL, path = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_gcloud()", + details = 'Learn more at ' + ) + board <- legacy_gcloud( name = name, bucket = bucket, diff --git a/R/legacy_github.R b/R/legacy_github.R index 533da2bf..003f2b5e 100644 --- a/R/legacy_github.R +++ b/R/legacy_github.R @@ -1,5 +1,7 @@ #' GitHub board (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' To use a GitHub board, you'll need to set up authentication, following #' the instructions at . #' @@ -29,15 +31,15 @@ #' board <- legacy_github("owner/repo") #' } #' @export -legacy_github <- function( - repo, - branch = NULL, - token = NULL, - path = "", - host = "https://api.github.com", - name = "github", - cache = NULL, - ...) { +#' @keywords internal +legacy_github <- function(repo, + branch = NULL, + token = NULL, + path = "", + host = "https://api.github.com", + name = "github", + cache = NULL, + ...) { cache <- cache %||% board_cache_path(name) @@ -97,6 +99,12 @@ board_register_github <- function(name = "github", host = "https://api.github.com", cache = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_github()", + details = 'Learn more at ' + ) + board <- legacy_github( name = name, repo = repo, diff --git a/R/legacy_kaggle.R b/R/legacy_kaggle.R index 3a0e6c2e..1111f655 100644 --- a/R/legacy_kaggle.R +++ b/R/legacy_kaggle.R @@ -1,5 +1,7 @@ #' Kaggle board (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' These functions are no longer supported because of changes to the Kaggle #' API and will be removed in a future version of pins. We recommend that you #' use the [Kaggle CLI](https://www.kaggle.com/docs/api) instead. @@ -52,6 +54,11 @@ board_register_kaggle <- function(name = "kaggle", token = NULL, cache = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_kaggle()", + details = 'Learn more at ' + ) cache <- cache %||% board_cache_path(name) diff --git a/R/legacy_local.R b/R/legacy_local.R index fc272cad..82527e60 100644 --- a/R/legacy_local.R +++ b/R/legacy_local.R @@ -1,6 +1,8 @@ #' Local board (legacy API) #' #' @description +#' `r lifecycle::badge('deprecated')` +#' #' `legacy_local()` powers `board_register_local()`, which allows you to #' access local pins created in earlier versions of the pins package. For #' new pins, we recommend that you transition to [board_local()] which @@ -14,6 +16,7 @@ #' to a system **cache** directory, which may be deleted by the operating #' system if you run out of disk space. #' @export +#' @keywords internal #' @examplesIf rlang::is_installed("filelock") #' # Old api #' pin(data.frame(x = 1:3), "test") @@ -38,6 +41,11 @@ legacy_local <- function(path = NULL, name = "local", versions = FALSE) { #' @rdname legacy_local #' @export board_register_local <- function(name = "local", cache = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_local()", + details = 'Learn more at ' + ) board <- legacy_local(path = cache, name = name, ...) board_register2(board) } diff --git a/R/legacy_pin_download.R b/R/legacy_pin_download.R index 3486cf5a..6c6f5ab5 100644 --- a/R/legacy_pin_download.R +++ b/R/legacy_pin_download.R @@ -193,6 +193,7 @@ pin_extract <- function(file, destination) { UseMethod("pin_extract") } +#' @export pin_extract.zip <- function(file, destination) { check_installed("zip") pin_log("Extracting zip file '", file, "'") @@ -200,6 +201,7 @@ pin_extract.zip <- function(file, destination) { unlink(file) } +#' @export pin_extract.gzip <- function(file, destination) { if (length(find.package("R.utils", quiet = TRUE)) == 0) { warning("To extract gzip pins install the 'R.utils' package") @@ -208,12 +210,14 @@ pin_extract.gzip <- function(file, destination) { } } +#' @export `pin_extract.compressed-tar` <- function(file, destination) { pin_log("Extracting tgz file '", file, "'") utils::untar(file, exdir = destination) unlink(file) } +#' @export pin_extract.default <- function(file, destination) { ext_map <- list( "\\.tar\\.gz$" = `pin_extract.compressed-tar`, diff --git a/R/legacy_s3.R b/R/legacy_s3.R index 7930eab8..7b2d9112 100644 --- a/R/legacy_s3.R +++ b/R/legacy_s3.R @@ -1,6 +1,8 @@ #' S3 board (legacy API) #' #' @description +#' `r lifecycle::badge('deprecated')` +#' #' To use an Amazon S3 Storage board, you need an Amazon S3 bucket and a user #' with enough permissions to access the S3 bucket. You can sign-up and create #' those at . Note that it can take a few minutes @@ -26,6 +28,7 @@ #' board <- legacy_s3(bucket = "s3bucket") #' } #' @export +#' @keywords internal legacy_s3 <- function( bucket = Sys.getenv("AWS_BUCKET"), key = Sys.getenv("AWS_ACCESS_KEY_ID"), @@ -67,6 +70,12 @@ board_register_s3 <- function(name = "s3", region = NULL, path = NULL, ...) { + lifecycle::deprecate_soft( + "1.4.0", + "board_register_s3()", + details = 'Learn more at ' + ) + legacy_s3( name = name, bucket = bucket, diff --git a/R/legacy_test.R b/R/legacy_test.R index 4c71bc16..22890c22 100644 --- a/R/legacy_test.R +++ b/R/legacy_test.R @@ -1,5 +1,7 @@ #' Test Board #' +#' `r lifecycle::badge('deprecated')` +#' #' Tests a particular board, useful only when creating new boards. #' #' @param board The name of the board to test. diff --git a/R/pin.R b/R/pin.R index aacb2277..87e558db 100644 --- a/R/pin.R +++ b/R/pin.R @@ -1,5 +1,7 @@ #' Pin a resource (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' Pins the given resource locally or to the given board. #' #' @param x An object, local file or remote URL to pin. @@ -38,7 +40,9 @@ #' board %>% pin_read("mtcars") #' #' @export +#' @keywords internal pin <- function(x, name = NULL, description = NULL, board = NULL, ...) { + lifecycle::deprecate_soft("1.4.0", "pin()", "pin_write()") UseMethod("pin") } diff --git a/R/pin_find.R b/R/pin_find.R index 40a3b231..d2e9125d 100644 --- a/R/pin_find.R +++ b/R/pin_find.R @@ -1,5 +1,7 @@ #' Search for pins (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' Search for pins in legacy boards. #' #' @param text The text to find in the pin description or name. @@ -14,12 +16,14 @@ #' board <- board_local() #' board %>% pin_search("cars") #' @export +#' @keywords internal pin_find <- function(text = NULL, board = NULL, name = NULL, extended = FALSE, metadata = FALSE, ...) { + lifecycle::deprecate_soft("1.4.0", "pin_find()", "pin_search()") if (is.null(board)) { boards <- lapply(board_list(), board_get) diff --git a/R/pin_get.R b/R/pin_get.R index b8423a40..4fd363d9 100644 --- a/R/pin_get.R +++ b/R/pin_get.R @@ -1,5 +1,7 @@ #' Retrieve a pin (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' Retrieves a pin by name from the local or given board. #' #' @param name The name of the pin. @@ -28,6 +30,7 @@ #' # retrieve the mtcars pin #' pin_get("mtcars", board = board) #' @export +#' @keywords internal pin_get <- function(name, board = NULL, cache = TRUE, @@ -36,6 +39,7 @@ pin_get <- function(name, files = FALSE, signature = NULL, ...) { + lifecycle::deprecate_soft("1.4.0", "pin_get()", "pin_read()") board <- board_get(board) if (!cache) { diff --git a/R/pin_info.R b/R/pin_info.R index 9c1c1f20..e6368527 100644 --- a/R/pin_info.R +++ b/R/pin_info.R @@ -1,5 +1,7 @@ #' Retrieve pin metadata (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' Retrieve metadata for pins in legacy boards. #' #' @param name The exact name of the pin to match when searching. @@ -20,12 +22,14 @@ #' board %>% pin_write(mtcars) #' board %>% pin_meta("mtcars") #' @export +#' @keywords internal pin_info <- function(name, board = NULL, extended = TRUE, metadata = TRUE, signature = FALSE, ...) { + lifecycle::deprecate_soft("1.4.0", "pin_info()", "pin_meta()") if (is.board(board) && !0 %in% board$api) { this_not_that("pin_meta", "pin_info") diff --git a/R/pin_reactive.R b/R/pin_reactive.R index 8addb0a5..05fa0966 100644 --- a/R/pin_reactive.R +++ b/R/pin_reactive.R @@ -1,5 +1,7 @@ #' Reactive Pin (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' Creates a pin that reacts to changes in the given board by #' polling `pin_get()`, useful when used from the `shiny` #' package. @@ -15,7 +17,10 @@ #' deefault behavior. #' #' @export +#' @keywords internal pin_reactive <- function(name, board, interval = 5000, session = NULL, extract = NULL) { + lifecycle::deprecate_soft("1.4.0", "pin_reactive()", "pin_reactive_read()") + board_object <- board_get(board) shiny::reactivePoll( diff --git a/R/pin_remove.R b/R/pin_remove.R index d6755ac5..b55e1f0a 100644 --- a/R/pin_remove.R +++ b/R/pin_remove.R @@ -1,5 +1,7 @@ #' Delete a pin (legacy API) #' +#' `r lifecycle::badge('deprecated')` +#' #' Deletes pins from a legacy board. #' #' @param name The name for the pin. @@ -16,7 +18,9 @@ #' board %>% pin_write(mtcars) #' board %>% pin_delete("mtcars") #' @export +#' @keywords internal pin_remove <- function(name, board = NULL) { + lifecycle::deprecate_soft("1.4.0", "pin_remove()", "pin_delete()") board <- board_get(board) board_pin_remove(board, name) invisible(NULL) diff --git a/README.Rmd b/README.Rmd index c6cea8e7..d73db6a2 100644 --- a/README.Rmd +++ b/README.Rmd @@ -26,7 +26,7 @@ knitr::opts_chunk$set( The pins package publishes data, models, and other R objects, making it easy to share them across projects and with your colleagues. -You can pin objects to a variety of pin *boards*, including folders (to share on a networked drive or with services like DropBox), Posit Connect, Amazon S3, Google Cloud Storage, Azure storage, and Microsoft 365 (OneDrive and SharePoint). +You can pin objects to a variety of pin *boards*, including folders (to share on a networked drive or with services like DropBox), Posit Connect, Databricks, Amazon S3, Google Cloud Storage, Azure storage, and Microsoft 365 (OneDrive and SharePoint). Pins can be automatically versioned, making it straightforward to track changes, re-run analyses on historical data, and undo mistakes. You can use pins from Python as well as R. For example, you can use one language to read a pin created with the other. Learn more about [pins for Python](https://rstudio.github.io/pins-python/). @@ -81,12 +81,12 @@ To get started, you can use `board_folder()` with a directory on a shared drive ```{r} #| eval: false board <- board_connect() -#> Connecting to Posit Connect 2023.01.0 at +#> Connecting to Posit Connect 2024.08.0 at board %>% pin_write(tidy_sales_data, "sales-summary", type = "rds") #> Writing to pin 'hadley/sales-summary' ``` -Then, someone else (or an automated Rmd report) can read and use your pin: +Then, someone else (or an automated Quarto report) can read and use your pin: ```{r} #| eval: false @@ -96,5 +96,5 @@ board %>% pin_read("hadley/sales-summary") You can easily control who gets to access the data using the Posit Connect permissions pane. -The pins package also includes boards that allow you to share data on services like Amazon's S3 (`board_s3()`), Azure's blob storage (`board_azure()`), and Google Cloud Storage (`board_gcs()`). +The pins package also includes boards that allow you to share data on services like Databricks Volumes (`board_databricks()`), Amazon's S3 (`board_s3()`), Azure's blob storage (`board_azure()`), and Google Cloud Storage (`board_gcs()`). Learn more in `vignette("pins")`. diff --git a/README.md b/README.md index c851c7be..295c4c41 100644 --- a/README.md +++ b/README.md @@ -15,18 +15,11 @@ stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https:// The pins package publishes data, models, and other R objects, making it easy to share them across projects and with your colleagues. You can pin objects to a variety of pin *boards*, including folders (to share on a -networked drive or with services like DropBox), Posit Connect, Amazon -S3, Google Cloud Storage, Azure storage, and Microsoft 365 (OneDrive and -SharePoint). Pins can be automatically versioned, making it -straightforward to track changes, re-run analyses on historical data, -and undo mistakes. - -pins 1.0.0 includes a new more explicit API and greater support for -versioning. The legacy API (`pin()`, `pin_get()`, and -`board_register()`) will continue to work, but new features will only be -implemented with the new API, so we encourage you to switch to the -modern API as quickly as possible. Learn more in -`vignette("pins-update")`. +networked drive or with services like DropBox), Posit Connect, +Databricks, Amazon S3, Google Cloud Storage, Azure storage, and +Microsoft 365 (OneDrive and SharePoint). Pins can be automatically +versioned, making it straightforward to track changes, re-run analyses +on historical data, and undo mistakes. You can use pins from Python as well as R. For example, you can use one language to read a pin created with the other. Learn more about [pins @@ -63,7 +56,7 @@ board <- board_temp() board #> Pin board #> Path: -#> '/var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T/Rtmpvoaxgw/pins-142d05cc7724a' +#> '/var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T/Rtmp4ETVv9/pins-28f423d40e5' #> Cache size: 0 ``` @@ -73,7 +66,7 @@ arguments: the board to pin to, an object, and a name: ``` r board %>% pin_write(head(mtcars), "mtcars") #> Guessing `type = 'rds'` -#> Creating new version '20231108T211157Z-8df40' +#> Creating new version '20241003T231743Z-8dce8' #> Writing to pin 'mtcars' ``` @@ -104,12 +97,12 @@ Connect](https://posit.co/products/enterprise/connect/) you can use ``` r board <- board_connect() -#> Connecting to Posit Connect 2023.01.0 at +#> Connecting to Posit Connect 2024.08.0 at board %>% pin_write(tidy_sales_data, "sales-summary", type = "rds") #> Writing to pin 'hadley/sales-summary' ``` -Then, someone else (or an automated Rmd report) can read and use your +Then, someone else (or an automated Quarto report) can read and use your pin: ``` r @@ -121,6 +114,6 @@ You can easily control who gets to access the data using the Posit Connect permissions pane. The pins package also includes boards that allow you to share data on -services like Amazon’s S3 (`board_s3()`), Azure’s blob storage -(`board_azure()`), and Google Cloud Storage (`board_gcs()`). Learn more -in `vignette("pins")`. +services like Databricks Volumes (`board_databricks()`), Amazon’s S3 +(`board_s3()`), Azure’s blob storage (`board_azure()`), and Google Cloud +Storage (`board_gcs()`). Learn more in `vignette("pins")`. diff --git a/_pkgdown.yml b/_pkgdown.yml index b6412094..96822f53 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -52,21 +52,6 @@ reference: - board_cache_path - write_board_manifest -- title: Legacy API - desc: > - These functions implement the legacy pins API. They will continue to exist - for some time so your existing code will continue to work, but we recommend - you move to the modern API and modern boards where possible. Learn - more in `vignettes("pins-update")`. - contents: - - starts_with("legacy_") - - pin - - pin_get - - pin_info - - pin_find - - pin_remove - - pin_reactive - news: releases: - text: pins 1.1.0 diff --git a/man/board_connect.Rd b/man/board_connect.Rd index b6bfabd4..5bcbfd4c 100644 --- a/man/board_connect.Rd +++ b/man/board_connect.Rd @@ -93,7 +93,7 @@ setting the access type to \code{all}: Now anyone can read your pin through \code{\link[=board_url]{board_url()}}: \if{html}{\out{
}}\preformatted{board <- board_url(c( - numbers = "https://colorado.posit.co/rsc/great-numbers/" + numbers = "https://pub.current.posit.team/public/great-numbers/" )) board \%>\% pin_read("numbers") }\if{html}{\out{
}} diff --git a/man/board_connect_url.Rd b/man/board_connect_url.Rd index 1b15bf55..cc0b6948 100644 --- a/man/board_connect_url.Rd +++ b/man/board_connect_url.Rd @@ -49,7 +49,7 @@ This board is a thin wrapper around \code{\link[=board_url]{board_url()}} which connect_auth_headers() board <- board_connect_url(c( - my_vanity_url_pin = "https://colorado.posit.co/rsc/great-numbers/" + my_vanity_url_pin = "https://pub.current.posit.team/public/great-numbers/" )) board \%>\% pin_read("my_vanity_url_pin") diff --git a/man/board_folder.Rd b/man/board_folder.Rd index f6d29dfc..43fe3987 100644 --- a/man/board_folder.Rd +++ b/man/board_folder.Rd @@ -37,8 +37,8 @@ board <- board_temp() } \seealso{ Other boards: -\code{\link{board_connect_url}()}, \code{\link{board_connect}()}, +\code{\link{board_connect_url}()}, \code{\link{board_url}()} } \concept{boards} diff --git a/man/board_register.Rd b/man/board_register.Rd index bf388a70..2f85ef3f 100644 --- a/man/board_register.Rd +++ b/man/board_register.Rd @@ -30,6 +30,8 @@ board_list() board_get(name) } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + The legacy pins API uses a board registry, where you first register a board then refer to it by name in calls to pin functions. } diff --git a/man/board_test.Rd b/man/board_test.Rd index 912f89c4..4053bca5 100644 --- a/man/board_test.Rd +++ b/man/board_test.Rd @@ -15,6 +15,9 @@ board_test(board, exclude = list(), suite = c("default", "versions")) \code{default} are supported.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ Tests a particular board, useful only when creating new boards. } \keyword{internal} diff --git a/man/board_url.Rd b/man/board_url.Rd index 5e67494f..e7fa2930 100644 --- a/man/board_url.Rd +++ b/man/board_url.Rd @@ -108,8 +108,8 @@ b2 \%>\% pin_versions("y") } \seealso{ Other boards: -\code{\link{board_connect_url}()}, \code{\link{board_connect}()}, +\code{\link{board_connect_url}()}, \code{\link{board_folder}()} } \concept{boards} diff --git a/man/custom-boards.Rd b/man/custom-boards.Rd index 17235300..4e01d969 100644 --- a/man/custom-boards.Rd +++ b/man/custom-boards.Rd @@ -41,6 +41,9 @@ board_pin_versions(board, name, ...) \item{text}{The text pattern to find a pin.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ Family of functions meant to be used to implement custom boards extensions, not to be used by users. } diff --git a/man/legacy_azure.Rd b/man/legacy_azure.Rd index bb74b422..813c0dae 100644 --- a/man/legacy_azure.Rd +++ b/man/legacy_azure.Rd @@ -50,6 +50,8 @@ board object.} \item{path}{Subdirectory within \code{url}} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + To use Microsoft Azure Storage as a board, you'll need an Azure Storage account, an Azure Storage container, and an Azure Storage key. You can sign-up and create those at \href{https://portal.azure.com}{portal.azure.com}. @@ -64,3 +66,4 @@ board_register_azure( ) } } +\keyword{internal} diff --git a/man/legacy_datatxt.Rd b/man/legacy_datatxt.Rd index 74b9d506..729a5eac 100644 --- a/man/legacy_datatxt.Rd +++ b/man/legacy_datatxt.Rd @@ -50,6 +50,9 @@ board object.} \item{...}{Additional parameters required to initialize a particular board.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ Use board that for a website that uses the \href{https://datatxt.org}{data.txt} specification. A \code{data.txt} file is a YAML that provides some basic metadata about a directory of files. @@ -66,3 +69,4 @@ board_register_datatxt( # find pins pin_find(board = "txtexample") } +\keyword{internal} diff --git a/man/legacy_dospace.Rd b/man/legacy_dospace.Rd index 13af88d5..f9bd9b8d 100644 --- a/man/legacy_dospace.Rd +++ b/man/legacy_dospace.Rd @@ -56,6 +56,9 @@ board object.} \item{path}{Subdirectory within \code{url}} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ To use DigitalOcean Spaces as a board, you first need an DigitalOcean space and a storage key. You can sign-up and create those at \href{https://www.digitalocean.com/}{digitalocean.com}. @@ -66,3 +69,4 @@ those at \href{https://www.digitalocean.com/}{digitalocean.com}. board <- legacy_dospace(bucket = "s3bucket") } } +\keyword{internal} diff --git a/man/legacy_gcloud.Rd b/man/legacy_gcloud.Rd index a677dc96..129ad40b 100644 --- a/man/legacy_gcloud.Rd +++ b/man/legacy_gcloud.Rd @@ -47,6 +47,9 @@ board object.} \item{path}{Subdirectory within \code{url}} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ To use a Google Cloud Storage board, you first need a Google Cloud Storage account, a Google Storage bucket, and an access token or the \href{https://cloud.google.com/sdk/}{Google Cloud SDK} properly installed and @@ -59,3 +62,4 @@ configured. You can sign-up and create these from board <- legacy_gcloud(container = "gcloudcontainer") } } +\keyword{internal} diff --git a/man/legacy_github.Rd b/man/legacy_github.Rd index 95df07ab..bab2e84e 100644 --- a/man/legacy_github.Rd +++ b/man/legacy_github.Rd @@ -52,6 +52,9 @@ cache location for your operating system, but you can override if needed.} \item{...}{Additional parameters required to initialize a particular board.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ To use a GitHub board, you'll need to set up authentication, following the instructions at \url{https://happygitwithr.com/https-pat.html#https-pat}. } @@ -72,3 +75,4 @@ repo. board <- legacy_github("owner/repo") } } +\keyword{internal} diff --git a/man/legacy_kaggle.Rd b/man/legacy_kaggle.Rd index 0c0a99a0..f3c6b38b 100644 --- a/man/legacy_kaggle.Rd +++ b/man/legacy_kaggle.Rd @@ -24,11 +24,13 @@ downloading files multiple times. The default stores in a standard cache location for your operating system, but you can override if needed.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ These functions are no longer supported because of changes to the Kaggle API and will be removed in a future version of pins. We recommend that you use the \href{https://www.kaggle.com/docs/api}{Kaggle CLI} instead. -} -\details{ + To use a Kaggle board, you need to first download a token file from your account. } diff --git a/man/legacy_local.Rd b/man/legacy_local.Rd index 9f3b637a..ff4be214 100644 --- a/man/legacy_local.Rd +++ b/man/legacy_local.Rd @@ -30,6 +30,8 @@ cache location for your operating system, but you can override if needed.} \item{...}{Additional parameters required to initialize a particular board.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + \code{legacy_local()} powers \code{board_register_local()}, which allows you to access local pins created in earlier versions of the pins package. For new pins, we recommend that you transition to \code{\link[=board_local]{board_local()}} which @@ -50,3 +52,4 @@ board \%>\% pin_write(data.frame(x = 1:3), "test") board \%>\% pin_read("test") \dontshow{\}) # examplesIf} } +\keyword{internal} diff --git a/man/legacy_s3.Rd b/man/legacy_s3.Rd index a2b9d90a..bb9e9460 100644 --- a/man/legacy_s3.Rd +++ b/man/legacy_s3.Rd @@ -57,6 +57,8 @@ board object.} \item{path}{Subdirectory within \code{url}} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + To use an Amazon S3 Storage board, you need an Amazon S3 bucket and a user with enough permissions to access the S3 bucket. You can sign-up and create those at \url{https://aws.amazon.com/}. Note that it can take a few minutes @@ -70,3 +72,4 @@ See \code{\link[=board_s3]{board_s3()}} for a modern version of this legacy boar board <- legacy_s3(bucket = "s3bucket") } } +\keyword{internal} diff --git a/man/pin.Rd b/man/pin.Rd index 24a3bce2..d8ff771f 100644 --- a/man/pin.Rd +++ b/man/pin.Rd @@ -18,9 +18,11 @@ pin(x, name = NULL, description = NULL, board = NULL, ...) \item{...}{Additional parameters.} } \description{ -Pins the given resource locally or to the given board. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \details{ +Pins the given resource locally or to the given board. + \code{pin()} allows you to cache remote resources and intermediate results with ease. When caching remote resources, usually URLs, it will check for HTTP caching headers to avoid re-downloading when the remote result has not changed. @@ -50,3 +52,4 @@ board \%>\% pin_write(mtcars) board \%>\% pin_read("mtcars") \dontshow{\}) # examplesIf} } +\keyword{internal} diff --git a/man/pin_find.Rd b/man/pin_find.Rd index 71bdec07..d0c62c22 100644 --- a/man/pin_find.Rd +++ b/man/pin_find.Rd @@ -27,6 +27,9 @@ pin_find( \item{...}{Additional parameters.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ Search for pins in legacy boards. } \examples{ @@ -35,3 +38,4 @@ pin_find("cars") board <- board_local() board \%>\% pin_search("cars") } +\keyword{internal} diff --git a/man/pin_get.Rd b/man/pin_get.Rd index e6ddac22..4154db6d 100644 --- a/man/pin_get.Rd +++ b/man/pin_get.Rd @@ -35,9 +35,11 @@ to compute signature.} \item{...}{Additional parameters.} } \description{ -Retrieves a pin by name from the local or given board. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} } \details{ +Retrieves a pin by name from the local or given board. + \code{pin_get()} retrieves a pin by name and, by default, from the local board. You can use the \code{board} parameter to specify which board to retrieve a pin from. If a board is not specified, it will use \code{pin_find()} to find the pin across @@ -53,3 +55,4 @@ pin(mtcars, board = board) pin_get("mtcars", board = board) \dontshow{\}) # examplesIf} } +\keyword{internal} diff --git a/man/pin_info.Rd b/man/pin_info.Rd index 660acd0c..aabe3e59 100644 --- a/man/pin_info.Rd +++ b/man/pin_info.Rd @@ -27,6 +27,9 @@ pin_info( \item{...}{Additional parameters.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ Retrieve metadata for pins in legacy boards. } \examples{ @@ -42,3 +45,4 @@ board \%>\% pin_write(mtcars) board \%>\% pin_meta("mtcars") \dontshow{\}) # examplesIf} } +\keyword{internal} diff --git a/man/pin_reactive.Rd b/man/pin_reactive.Rd index fcb4d2f0..7c2712e1 100644 --- a/man/pin_reactive.Rd +++ b/man/pin_reactive.Rd @@ -22,7 +22,11 @@ none. If non-null, the reader will automatically stop when the session ends.} deefault behavior.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ Creates a pin that reacts to changes in the given board by polling \code{pin_get()}, useful when used from the \code{shiny} package. } +\keyword{internal} diff --git a/man/pin_remove.Rd b/man/pin_remove.Rd index 11ba43ec..458d8e04 100644 --- a/man/pin_remove.Rd +++ b/man/pin_remove.Rd @@ -12,6 +12,9 @@ pin_remove(name, board = NULL) \item{board}{The board from where this pin will be removed.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ Deletes pins from a legacy board. } \examples{ @@ -27,3 +30,4 @@ board \%>\% pin_write(mtcars) board \%>\% pin_delete("mtcars") \dontshow{\}) # examplesIf} } +\keyword{internal} diff --git a/tests/testthat/_snaps/board_url.md b/tests/testthat/_snaps/board_url.md index 27390034..112bcf97 100644 --- a/tests/testthat/_snaps/board_url.md +++ b/tests/testthat/_snaps/board_url.md @@ -47,11 +47,17 @@ Code pin(1:5, name = "x", board = board) Condition + Warning: + `pin()` was deprecated in pins 1.4.0. + i Please use `pin_write()` instead. Error in `board_pin_create()`: ! Use `pin_write()` with this board, not `pin()` Code pin_get(name = "x", board = board) Condition + Warning: + `pin_get()` was deprecated in pins 1.4.0. + i Please use `pin_read()` instead. Error in `board_pin_get()`: ! Use `pin_read()` with this board, not `pin_get()` diff --git a/tests/testthat/_snaps/legacy_board.md b/tests/testthat/_snaps/legacy_board.md index edcf34af..6d87cf57 100644 --- a/tests/testthat/_snaps/legacy_board.md +++ b/tests/testthat/_snaps/legacy_board.md @@ -4,16 +4,25 @@ board <- board_temp() pin(mtcars, "mtcars", board = board) Condition + Warning: + `pin()` was deprecated in pins 1.4.0. + i Please use `pin_write()` instead. Error in `board_pin_create()`: ! Use `pin_write()` with this board, not `pin()` Code pin_get("mtcars", board = board) Condition + Warning: + `pin_get()` was deprecated in pins 1.4.0. + i Please use `pin_read()` instead. Error in `board_pin_get()`: ! Use `pin_read()` with this board, not `pin_get()` Code pin_find("mtcars", board = board) Condition + Warning: + `pin_find()` was deprecated in pins 1.4.0. + i Please use `pin_search()` instead. Error in `board_pin_find()`: ! Use `pin_search()` with this board, not `pin_find()` Code diff --git a/tests/testthat/_snaps/legacy_local.md b/tests/testthat/_snaps/legacy_local.md deleted file mode 100644 index 8e6bf9d0..00000000 --- a/tests/testthat/_snaps/legacy_local.md +++ /dev/null @@ -1,4 +0,0 @@ -# can version a local pin - - Version 'doesnt-exist' is not valid, please select from pin_versions(). - diff --git a/tests/testthat/_snaps/pin.md b/tests/testthat/_snaps/pin.md deleted file mode 100644 index 22d4fc6f..00000000 --- a/tests/testthat/_snaps/pin.md +++ /dev/null @@ -1,25 +0,0 @@ -# unavailable url can use cache - - Code - pin(url, "test", board = board) - Condition - Error in `pin()`: - ! Client error: (404) Not Found. Failed to download remote file: http://127.0.0.1:/status/404 - Code - pin(1:10, "test", board = board) - x <- pin(url, "test", board = board) - Condition - Warning: - Failed to re-download pin; using cached value - * Client error: (404) Not Found. Failed to download remote file: http://127.0.0.1:/status/404 - Code - expect_equal(x, 1:10) - -# can pin() with custom metadata - - Code - pin(iris, "iris2", board = board, custom_metadata = meta) - Condition - Warning: - `custom_metadata` is deprecated; please use `metadata` instead - diff --git a/tests/testthat/_snaps/pin_info.md b/tests/testthat/_snaps/pin_info.md index cc5e3c3c..01533aac 100644 --- a/tests/testthat/_snaps/pin_info.md +++ b/tests/testthat/_snaps/pin_info.md @@ -48,6 +48,9 @@ board <- board_temp() pin_info("mtcars", board = board) Condition + Warning: + `pin_info()` was deprecated in pins 1.4.0. + i Please use `pin_meta()` instead. Error in `pin_info()`: ! Use `pin_meta()` with this board, not `pin_info()` diff --git a/tests/testthat/test-board_connect.R b/tests/testthat/test-board_connect.R index 2bb8a668..ec0c2759 100644 --- a/tests/testthat/test-board_connect.R +++ b/tests/testthat/test-board_connect.R @@ -12,14 +12,14 @@ test_that("get useful error for rebranding", { }) test_that("can round-trip a pin (v0)", { - board <- board_connect_colorado() - colorado_user_name <- rsconnect::accounts(server = "colorado.posit.co")$name + board <- board_connect_ptd() + ptd_user_name <- rsconnect::accounts(server = "pub.demo.posit.team")$name df1 <- data.frame(x = 1:5) pin(df1, "test-df1", board = board) - withr::defer(pin_delete(board, paste0(colorado_user_name, "/test-df1"))) + withr::defer(pin_delete(board, paste0(ptd_user_name, "/test-df1"))) - df2 <- pin_get(paste0(colorado_user_name, "/test-df1"), board = board) + df2 <- pin_get(paste0(ptd_user_name, "/test-df1"), board = board) expect_equal(df1, df2) }) @@ -69,7 +69,7 @@ test_that("can write pin created another user", { test_that("can deparse", { board <- new_board_v1( "pins_board_connect", - url = "https://colorado.posit.co/rsc", + url = "https://pub.demo.posit.team", cache = tempdir() ) expect_snapshot(board_deparse(board)) diff --git a/tests/testthat/test-legacy_azure.R b/tests/testthat/test-legacy_azure.R deleted file mode 100644 index 0142ac95..00000000 --- a/tests/testthat/test-legacy_azure.R +++ /dev/null @@ -1,37 +0,0 @@ -skip_if_not_installed("mime") -skip_if_not_installed("openssl") - -test_that("board contains proper azure headers", { - 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) - expect_true("x-ms-version" %in% headers) - expect_true("x-ms-blob-type" %in% headers) - expect_true("Authorization" %in% headers) -}) - -# Live API --------------------------------------------------------------------- - -skip_if_missing_envvars( - tests = "legacy_azure()", - envvars = c("TEST_AZURE_CONTAINER", "TEST_AZURE_ACCOUNT", "TEST_AZURE_KEY") -) - -board <- legacy_azure( - container = Sys.getenv("TEST_AZURE_CONTAINER"), - account = Sys.getenv("TEST_AZURE_ACCOUNT"), - key = Sys.getenv("TEST_AZURE_KEY"), - cache = tempfile() -) -board_test(board, suite = "default") - -board <- legacy_azure( - name = "test-azure-2", - container = Sys.getenv("TEST_AZURE_CONTAINER"), - account = Sys.getenv("TEST_AZURE_ACCOUNT"), - key = Sys.getenv("TEST_AZURE_KEY"), - versions = TRUE, - cache = tempfile() -) -board_test(board, suite = "versions") diff --git a/tests/testthat/test-legacy_datatxt.R b/tests/testthat/test-legacy_datatxt.R deleted file mode 100644 index ba3b0b7b..00000000 --- a/tests/testthat/test-legacy_datatxt.R +++ /dev/null @@ -1,51 +0,0 @@ -skip_if_not_installed("filelock") - -test_that("can board_register() a data.txt board", { - skip_on_cran() - - board_register_datatxt( - name = "simpletxt", - url = "https://raw.githubusercontent.com/rstudio/pins-r/master/tests/testthat/datatxt/data.txt", - cache = tempfile() - ) - - expect_true("simpletxt" %in% board_list()) -}) - -test_that("can pin_get() iris from a data.txt board", { - skip_on_cran() - - b <- local_legacy_datatxt() - iris <- pin_get("iris", board = b) - - expect_equal(dim(iris), c(150, 5)) -}) - -test_that("doen't evaluate expressions in data.txt", { - skip_on_cran() - - b <- local_legacy_datatxt() - json <- pin_find("mtcars_expr", board = b, metadata = TRUE)$metadata - meta <- jsonlite::fromJSON(json) - - expect_equal(meta$rows, "30+2") -}) - -test_that("can board_register() with URL", { - skip_on_cran() - - board_name <- board_register( - "https://raw.githubusercontent.com/rstudio/pins-r/master/tests/testthat/datatxt/data.txt", - name = "simpletxt", - cache = tempfile() - ) - withr::defer(board_deregister("simpletxt")) - expect_equal(board_name, "simpletxt") - - board_name <- board_register( - "https://raw.githubusercontent.com/rstudio/pins-r/master/tests/testthat/datatxt/data.txt", - cache = tempfile() - ) - withr::defer(board_deregister("raw")) - expect_equal(board_name, "raw") -}) diff --git a/tests/testthat/test-legacy_gcloud.R b/tests/testthat/test-legacy_gcloud.R deleted file mode 100644 index 98e534ec..00000000 --- a/tests/testthat/test-legacy_gcloud.R +++ /dev/null @@ -1,25 +0,0 @@ -skip_if_not_installed("mime") - -test_that("board contains proper gcloud headers", { - headers <- names(gcloud_headers(list(token = "abc"), "PUT", "x", "files/hello.txt")$headers) - - expect_true("Content-Type" %in% headers) - expect_true("Authorization" %in% headers) -}) - -# Live API --------------------------------------------------------------------- - -skip_if_missing_envvars("legacy_gcloud()", "TEST_GOOGLE_BUCKET") - -board <- legacy_gcloud( - bucket = Sys.getenv("TEST_GOOGLE_BUCKET"), - cache = tempfile() -) -board_test(board, suite = "default") - -board <- legacy_gcloud( - bucket = Sys.getenv("TEST_GOOGLE_BUCKET"), - versions = TRUE, - cache = tempfile() -) -board_test(board, suite = "versions") diff --git a/tests/testthat/test-legacy_github.R b/tests/testthat/test-legacy_github.R deleted file mode 100644 index e858830b..00000000 --- a/tests/testthat/test-legacy_github.R +++ /dev/null @@ -1,33 +0,0 @@ -skip_if_missing_envvars( - tests = "legacy_github()", - envvars = c("TEST_GITHUB_REPO", "TEST_GITHUB_BRANCH") -) - -board <- legacy_github( - repo = Sys.getenv("TEST_GITHUB_REPO"), - branch = Sys.getenv("TEST_GITHUB_BRANCH"), - cache = tempfile() -) - -board_test(board, suite = "default") -board_test(board, suite = "versions") - -test_that("can pin large resources in github releases", { - pin(iris, "iris_large", board = board, release_storage = TRUE) - - retrieved <- pin_get("iris_large", board = board) - - expect_true(is.data.frame(retrieved)) - - pin_remove("iris_large", board = board) - - expect_true(!"iris_large" %in% pin_find(board = board)$name) -}) - -test_that("uninitialized repo returns empty results", { - skip_if_missing_envvars("legacy_github()", "GITHUB_PAT") - - board <- legacy_github("rstudio/sparklyr", cache = tempfile()) - total <- nrow(pin_find("", board = board)) - expect_equal(total, 0) -}) diff --git a/tests/testthat/test-legacy_local.R b/tests/testthat/test-legacy_local.R deleted file mode 100644 index 96a06b0b..00000000 --- a/tests/testthat/test-legacy_local.R +++ /dev/null @@ -1,45 +0,0 @@ -skip_if_not_installed("filelock") - -board_test(legacy_temp(), suite = "default") -board_test(legacy_temp(versions = TRUE), suite = "versions") - -test_that("local board registered by default", { - expect_true("local" %in% board_list()) -}) - -test_that(paste("can add and delete pin"), { - b <- legacy_temp() - expect_equal(pin_list(b), character()) - - hello <- test_path("files/hello.txt") - path <- pin(hello, board = b) - expect_equal(pin_list(b), "hello") - - expect_true(file.exists(path)) - expect_equal(readLines(path), "hello world") - - pin_remove("hello", b) - expect_equal(pin_list(b), character()) -}) - -test_that("can version a local pin", { - b <- legacy_temp(versions = TRUE) - - versions <- pin_versions("df", b) - expect_equal(versions, data.frame()) - - pin(data.frame(x = 1), "df", board = b) - pin(data.frame(x = 2), "df", board = b) - pin(data.frame(x = 3), "df", board = b) - - versions <- pin_versions("df", b) - expect_equal(nrow(versions), 3) - - newest <- pin_get("df", version = versions$version[[1]], board = b) - oldest <- pin_get("df", version = versions$version[[3]], board = b) - expect_equal(newest$x, 3) - expect_equal(oldest$x, 1) - - expect_snapshot_error(pin_get("df", version = "doesnt-exist", board = b)) -}) - diff --git a/tests/testthat/test-legacy_packages.R b/tests/testthat/test-legacy_packages.R index f805a9bc..c14cd67d 100644 --- a/tests/testthat/test-legacy_packages.R +++ b/tests/testthat/test-legacy_packages.R @@ -1,4 +1,5 @@ test_that("can pin_find() package data", { + withr::local_options(lifecycle_verbosity = "quiet") board <- board_packages() results <- pin_find(board = board) @@ -12,12 +13,14 @@ test_that("can pin_find() package data", { }) test_that("can retrieve data from a package", { + withr::local_options(lifecycle_verbosity = "quiet") board <- board_packages() data <- pin_get("datasets/AirPassengers", board = board) expect_equal(data, datasets::AirPassengers) }) test_that("bad pin names give useful errors", { + withr::local_options(lifecycle_verbosity = "quiet") board <- board_packages() expect_snapshot(error = TRUE, { diff --git a/tests/testthat/test-legacy_s3.R b/tests/testthat/test-legacy_s3.R deleted file mode 100644 index 61ce47e4..00000000 --- a/tests/testthat/test-legacy_s3.R +++ /dev/null @@ -1,37 +0,0 @@ -skip_if_not_installed("openssl") - -test_that("board contains proper s3 headers", { - headers <- names(s3_headers(list(), "PUT", "x")$headers) - - expect_true("Host" %in% headers) - expect_true("Date" %in% headers) - expect_true("Content-Type" %in% headers) - expect_true("Authorization" %in% headers) -}) - -# Live API --------------------------------------------------------------------- - -skip_if_missing_envvars( - tests = "legacy_s3()", - envvars = c("TEST_AWS_BUCKET", "TEST_AWS_KEY", "TEST_AWS_SECRET", "TEST_AWS_REGION") -) - -board <- legacy_s3( - bucket = Sys.getenv("TEST_AWS_BUCKET"), - key = Sys.getenv("TEST_AWS_KEY"), - secret = Sys.getenv("TEST_AWS_SECRET"), - cache = tempfile(), - region = Sys.getenv("TEST_AWS_REGION") -) -board_test(board, suite = "default") - -board <- legacy_s3( - name = "test-s3-2", - bucket = Sys.getenv("TEST_AWS_BUCKET"), - key = Sys.getenv("TEST_AWS_KEY"), - secret = Sys.getenv("TEST_AWS_SECRET"), - versions = TRUE, - cache = tempfile(), - region = Sys.getenv("TEST_AWS_REGION") -) -board_test(board, suite = "versions") diff --git a/tests/testthat/test-pin.R b/tests/testthat/test-pin.R deleted file mode 100644 index 9a063efb..00000000 --- a/tests/testthat/test-pin.R +++ /dev/null @@ -1,123 +0,0 @@ -skip_if_not_installed("filelock") -skip_if_not_installed("webfakes") -skip_on_cran() - -httpbin <- local_httpbin_app() -httpbin_port <- httpbin$get_port() -redact_port <- function(snapshot) { - snapshot <- gsub(httpbin_port, "", snapshot, fixed = TRUE) -} - -# main types -------------------------------------------------------------- - -test_that("can pin() a data frame", { - board <- legacy_temp() - - df <- data.frame( - raw = charToRaw("asdas"), - posix = as.POSIXlt(Sys.time(), "EST"), - date = as.Date(35981, origin = "1899-12-30"), - integer = 1L, - numeric = 1, - logical = TRUE, - stringsAsFactors = FALSE - ) - pin(df, "df", board = board) - expect_equal(pin_get("df", board = board), df) -}) - -test_that("can pin() a data.table", { - skip_if_not_installed("data.table") - board <- legacy_temp() - - dt <- data.table::data.table(x = 1:2, y = list("a", "b")) - pin(dt, "dt", board = board) - expect_equal(pin_get("dt", board = board), dt) - - # Check that pin_safe_csv() hasn't mutated original data.table - expect_named(dt, c("x", "y")) -}) - -test_that("can pin an arbitrary object", { - board <- legacy_temp() - - x <- list(1, letters, c(TRUE, FALSE, NA)) - pin(x, "x", board = board) - expect_equal(pin_get("x", board = board), x) -}) - -test_that("AsIs class stripped when using I", { - board <- legacy_temp() - - df <- data.frame(x = 1) - pin(I(df), "df", board = board) - expect_equal(pin_get("df", board = board), df) -}) - -test_that("can pin a file", { - board <- legacy_temp() - - pin(test_path("files/hello.txt"), "hello", board = board) - expect_equal( - pin_get("hello", board = board), - as.character(pin_registry_path(board, "hello", "hello.txt")) - ) -}) - -test_that("can pin() remote CSV with URL and name", { - board <- legacy_temp() - - url <- "https://raw.githubusercontent.com/rstudio/pins-r/master/tests/testthat/datatxt/iris/data.csv" - pin <- pin(url, "iris", board = board) - - expect_equal(dim(read.csv(pin)), c(150, 5)) -}) - -test_that("unavailable url can use cache", { - skip_on_cran() - board <- legacy_temp() - url <- httpbin$url("/status/404") - - expect_snapshot({ - pin(url, "test", board = board) - pin(1:10, "test", board = board) - x <- pin(url, "test", board = board) - expect_equal(x, 1:10) - }, error = TRUE, transform = redact_port) -}) - -# custom metadata ------------------------------------------------------------------- - -test_that("can pin() with custom metadata", { - withr::local_options(lifecycle_verbosity = "quiet") - board <- legacy_temp() - - meta <- list( - source = "The R programming language", - extra_info = list( - list(name = "Species", description = "Really like this column"), - list(name = "Sepal.Length", description = "Sepal Length"), - list(name = "Sepal.Width", description = "Sepal Width"), - list(name = "Petal.Length", description = "Petal Length"), - list(name = "Petal.Width", description = "Petal Width") - ) - ) - pin(iris, "iris", metadata = meta, board = board) - meta2 <- pin_info("iris", board) - expect_equal(meta2[c("source", "extra_info")], meta) - - expect_snapshot(pin(iris, "iris2", board = board, custom_metadata = meta)) - meta2 <- pin_info("iris2", board) - expect_equal(meta2[c("source", "extra_info")], meta) -}) - -# helpers ----------------------------------------------------------------- - -test_that("can sanitize data frame names", { - name <- "___sdf ds32___42342 dsf dsf dsfds____" - expect_equal( - pin_default_name(name, board_temp()), - "sdf-ds32-42342-dsf-dsf-dsfds" - ) -}) - diff --git a/tests/testthat/test-pin_versions.R b/tests/testthat/test-pin_versions.R index 7ceffd53..8939058e 100644 --- a/tests/testthat/test-pin_versions.R +++ b/tests/testthat/test-pin_versions.R @@ -1,6 +1,7 @@ skip_if_not_installed("filelock") test_that("can use old pin_versions() api", { + withr::local_options(lifecycle_verbosity = "quiet") board <- legacy_local() pin(x = 1:5, "x", board = board) withr::defer(pin_remove("x", board)) diff --git a/vignettes/pins-update.Rmd b/vignettes/pins-update.Rmd index be6f6e38..f0894d87 100644 --- a/vignettes/pins-update.Rmd +++ b/vignettes/pins-update.Rmd @@ -15,8 +15,7 @@ knitr::opts_chunk$set( ) ``` -pins 1.0.0 introduced a completely new API. -While the legacy API will continue to be supported for some time, it will not gain any new features, so it's good to plan to switch to the new interface. +pins 1.0.0 introduced a completely new API and the old legacy API was deprecated in pins 1.4.0, so now is a good time to switch to the new interface. This vignette shows a couple of examples of updating legacy code to the modern API, then provides a full set of equivalences between the legacy and modern function names. ```{r setup}