rstudio / pins-r

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

Check that version is not the same #727

Closed juliasilge closed 1 year ago

juliasilge commented 1 year ago

Closes #601

This PR checks whether the new and old versions are the same, as can happen when writing pins very fast. What do we think of this error message?

library(pins)
b <- board_temp(version = TRUE)
pin_write(b, iris)
#> Using `name = 'iris'`
#> Guessing `type = 'rds'`
#> Creating new version '20230302T194159Z-8dff5'
#> Writing to pin 'iris'
pin_write(b, iris)
#> Using `name = 'iris'`
#> Guessing `type = 'rds'`
#> Error in `version_setup()` at pins-r/R/board_folder.R:76:2:
#> ! The new version 20230302T194159Z-8dff5 is the same as the most recent
#>   version.
#> ℹ Did you try to create a new version with the same timestamp as the last
#>   version?

#> Backtrace:
#>     ▆
#>  1. └─pins::pin_write(b, iris)
#>  2.   ├─pins::pin_store(...) at pins-r/R/pin-read-write.R:114:2
#>  3.   └─pins:::pin_store.pins_board_folder(...) at pins-r/R/pin-store-fetch.R:25:2
#>  4.     └─pins:::version_setup(board, name, version_name(metadata), versioned = versioned) at pins-r/R/board_folder.R:76:2
#>  5.       └─cli::cli_abort(...) at pins-r/R/pin_versions.R:173:6
#>  6.         └─rlang::abort(...)

Created on 2023-03-02 with reprex v2.0.2

Refined this message in commit c5b0baa2c17df73453d43967ff126e72510f6047

Probably could wait for the testthat release for this one as well.

juliasilge commented 1 year ago

Oh, this needs the changes from #724 because otherwise the vignettes are checked with all the same version. I may not need those Sys.sleep() additions.

github-actions[bot] commented 1 year ago

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.