Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhanced wrapper to pin_versions #261

Open
tbowling87 opened this issue Nov 16, 2023 · 2 comments
Open

enhanced wrapper to pin_versions #261

tbowling87 opened this issue Nov 16, 2023 · 2 comments

Comments

@tbowling87
Copy link

tbowling87 commented Nov 16, 2023

Big fan of the package. One addition I think would be really helpful would be to get a bit of a model description included in the output of the call to pin_versions - which I think might fit best inside of vetiver. As if you've iterated many times over the model selection process you might not remember exactly what version 1 was, and unless I'm missing something, you currently have to read the model pin for each version to see the specifics.

I created a very minimal example of this that I've found helpful in keeping track of things. Other things like a list of the model terms could also be useful but not critical
`vetiver_pin_versions <- function(board, name){
versions <- pins::pin_versions(board, name)

versions <- versions |>
dplyr::mutate(description = purrr::map_chr(version,
~format(vetiver_pin_read(board, name, version = .x))[3]))

return(versions)
}`

@juliasilge
Copy link
Member

Thanks for the feedback @tbowling87! This is related to rstudio/pins-r#758 and rstudio/pins-r#769. One thing that I notice is that folks really have heterogeneous needs in terms of what they want to combine with version in a rectangular kind of format. This makes me think that we should focus on modular functions that can be put together in useful ways rather than supporting lots of different specific functions, but let's leave this issue open for a while to see if this resonates with people.

In your specific case, I would recommend using pin_meta() rather than vetiver_pin_read() because it will be faster to only get the metadata than read the whole model into memory, for realistic (big) models. Something like this:

library(tidyverse)
library(pins)
b <- board_connect()
#> Connecting to Posit Connect 2023.10.0 at <https://colorado.posit.co/rsc>

all_versions <- b |> pin_versions("julia.silge/sacramento-rf")

all_versions |> 
  mutate(all_meta = map(version, 
                        ~ pin_meta(b,
                                   "julia.silge/sacramento-rf",
                                   version = .))) |> 
  mutate(title = map_chr(all_meta, pluck, "description"))
#> # A tibble: 4 × 6
#>   version created             active   size all_meta   title                    
#>   <chr>   <dttm>              <lgl>   <dbl> <list>     <chr>                    
#> 1 75699   2023-06-09 15:42:00 TRUE   614776 <pins_met> A ranger regression mode…
#> 2 75698   2023-06-09 15:42:00 FALSE  606027 <pins_met> A ranger regression mode…
#> 3 66761   2022-12-10 09:55:00 FALSE  616737 <pins_met> A ranger regression mode…
#> 4 66749   2022-12-09 20:01:00 FALSE  601787 <pins_met> A ranger regression mode…

Created on 2023-11-16 with reprex v2.0.2

@tbowling87
Copy link
Author

thanks @juliasilge that sounds like a nice way to address the problem. I'll take a look at changing my helper function to use pin_meta as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants