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

combine pin_meta with pin_versions? #758

Closed
DOH-FAA3303 opened this issue Jul 13, 2023 · 4 comments
Closed

combine pin_meta with pin_versions? #758

DOH-FAA3303 opened this issue Jul 13, 2023 · 4 comments

Comments

@DOH-FAA3303
Copy link

DOH-FAA3303 commented Jul 13, 2023

pin_version() gives a tibble of all versions, create date and hash, but it's challenging to know what data a given version contains. pin_meta() will only return the specified pin's metadata, so we can't see any metadata for all pins.

For example, my team is making a lot of test datasets and using pins to keep track of them. Each time a test dataset is created the person creating it will write metadata giving their username and what is in the test pin. We need to get the pin_version and see what each version contains for ease of use.

pin_versions() isn't helpful as I can't see what metadata each pin version actually contains
image

pin_meta() is sort of helpful, but I can only see one pin_version at a time:
image

This is what I created - it allows us to use metadata in combination with the pin version list so we can see exactly what a user created and the pin version it corresponds to
image

I made it with this function (it's so terrible but I'm hoping someone else could help make it better)

get_pin_info <- function(name_of_pin_board,name_of_pin){
  
  versiondata <- name_of_pin_board %>%
    pin_versions(name_of_pin) 
  
  version <- c()
  commit_message <- c()
  user <- c()
  for(i in 1:length(versiondata$version)){
    temp <- name_of_pin_board %>% pin_meta(name_of_pin,version = versiondata$version[i])
    version <- c(version,temp$local$version)
    commit_message <- c(commit_message,temp$user$commit)
    user <- c(user,temp$user$author)
    
  }
  
  df2 <- tibble(version,commit_message,user)
  output <- inner_join(versiondata,df2,by = "version") %>% arrange(desc(created))
  
  return(output)
}
@juliasilge
Copy link
Member

Thanks for sharing your thoughts here @DOH-FAA3303! We can keep this issue open to see if this would be something that would be useful to a broad set of pins users. In the meantime, you can use code like this to get the information you need from your pins:

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

all_versions <- b |> pin_versions("julia.silge/traffic-crash-model-metrics")

all_versions |> 
  mutate(all_meta = map(version, 
                        ~ pin_meta(b,
                                   "julia.silge/traffic-crash-model-metrics",
                                   version = .))) |> 
  # you can use `pluck` here to get out whatever you want,
  # such as something in the user slot
  mutate(title = map_chr(all_meta, pluck, "title"))
#> # A tibble: 41 × 6
#>    version created             active  size all_meta   title                    
#>    <chr>   <dttm>              <lgl>  <dbl> <list>     <chr>                    
#>  1 76347   2023-06-24 19:07:00 TRUE   28435 <pins_met> traffic-crash-model-metr…
#>  2 75998   2023-06-17 19:08:00 FALSE  28357 <pins_met> traffic-crash-model-metr…
#>  3 75740   2023-06-10 19:08:00 FALSE  28256 <pins_met> traffic-crash-model-metr…
#>  4 75455   2023-06-03 19:08:00 FALSE  28207 <pins_met> traffic-crash-model-metr…
#>  5 75150   2023-05-27 19:08:00 FALSE  28103 <pins_met> traffic-crash-model-metr…
#>  6 74827   2023-05-20 19:08:00 FALSE  28035 <pins_met> traffic-crash-model-metr…
#>  7 74149   2023-05-13 19:08:00 FALSE  27952 <pins_met> traffic-crash-model-metr…
#>  8 73825   2023-05-06 19:08:00 FALSE  27852 <pins_met> traffic-crash-model-metr…
#>  9 73364   2023-04-29 19:08:00 FALSE  27778 <pins_met> traffic-crash-model-metr…
#> 10 73145   2023-04-22 19:08:00 FALSE  27714 <pins_met> traffic-crash-model-metr…
#> # ℹ 31 more rows

Created on 2023-07-14 with reprex v2.0.2

If you need something more deeply nested inside of the metadata object, you could do something like map_chr(all_meta, pluck, "user", "commit_message")

@DOH-FAA3303
Copy link
Author

@juliasilge this is great, thanks for the help!

@juliasilge
Copy link
Member

Thanks for the discussion @DOH-FAA3303! We can revisit this if it comes up as a high priority for more folks in the future.

@github-actions
Copy link

This issue 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.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants