rstudio / pins-r

Pin, discover, and share resources
https://pins.rstudio.com
Other
312 stars 63 forks source link

`pin_write` should return the `version` as well as the `name` #592

Open sellorm opened 2 years ago

sellorm commented 2 years ago

In the the current version of pins (1.0.1) pin_write() returns the fully qualified name of the new pin, invisibly.

library(pins)
board = board_folder("~/tmp/pins")
pinout <- pin_write(board, 
                    ggplot2::diamonds, 
                    name = "diamonds", 
                    type = "csv")
#> Replacing version '20220125T122254Z-c9e9b' with '20220125T122531Z-c9e9b'
#> Writing to pin 'diamonds'
str(pinout)
#>  chr "diamonds"

There are a number of additional workflows that would be enabled by also returning the version. In the example above, 20220125T122531Z-c9e9b.

This is useful, since both the "fully qualified name" and the version are required to obtain a specific version of a data set rather than just the latest version.

For example, users may want to record the versions of specific pins in another system and currently, this is not a straightforward task.

Perhaps pin_write(), could return a list that includes the fully qualified domain name as well as the version.

afshinmhCLG commented 2 years ago

Returning version would be a very useful feature! I rely on knowing the version prior to pinning so much that I have a wrapper/hack where I always pin into a local empty/temp location just to get the version and then pin to remote knowing what the version will be.

juliasilge commented 2 years ago

We could look into whether it's possible to return the whole metadata object invisibly for pin_write().

juliasilge commented 1 year ago

It turns out the meta object in this function doesn't contain the name or version (in fact, no metadata objects contain the name) so that's not really going to help us much here. 🙈 Instead, let's try returning a named list with name and version.

After working on this today, I believe that each pin_store method will need to be updated; it can't be done in pin_write() because that messes up the cache by making another API call.

juliasilge commented 1 year ago

In #735 we are looking at an argument to check the hash of the pin contents before pinning, so another possible component to consider returning is whether pinning was successful.