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

Make tags more consistent in YAML #697

Merged
merged 3 commits into from
Jan 21, 2023
Merged

Make tags more consistent in YAML #697

merged 3 commits into from
Jan 21, 2023

Conversation

juliasilge
Copy link
Member

@juliasilge juliasilge commented Jan 11, 2023

From @machow in rstudio/pins-python#175:

@juliasilge WDYT of us having R pins add tags metadata as either null or a list of strings? Currently, if you pin_write(..., tags="some_tag") it saves it as a string, rather than a list of strings.

AFAIK the result will be the same when reading meta into R (NULL or a vector of strings), so this is purely for convenience on the python side :) (which would be None, str, or list[str] right now)

With the change in this PR, now we will see the tags metadata represented the same in YAML whether there is one or more than one:

library(pins)
b <- board_temp()

b %>% pin_write(1:10, "nice-numbers", tags = "a-single-tag")
#> Guessing `type = 'rds'`
#> Creating new version '20230111T022854Z-4d1eb'
#> Writing to pin 'nice-numbers'
b %>% pin_write(100:10, "big-numbers", tags = c("a-single-tag", "another-tag"))
#> Guessing `type = 'rds'`
#> Creating new version '20230111T022854Z-02d96'
#> Writing to pin 'big-numbers'

cat(readr::read_lines(fs::path(
  b$path, 
  "nice-numbers", 
  pin_versions(b, "nice-numbers")$version, 
  "data.txt"
)), sep = "\n")
#> file: nice-numbers.rds
#> file_size: 61
#> pin_hash: 4d1eb93dc2188114
#> type: rds
#> title: 'nice-numbers: a pinned integer vector'
#> description: ~
#> tags:
#> - a-single-tag
#> created: 20230111T022854Z
#> api_version: 1.0

cat(readr::read_lines(fs::path(
  b$path, 
  "big-numbers", 
  pin_versions(b, "big-numbers")$version, 
  "data.txt"
)), sep = "\n")
#> file: big-numbers.rds
#> file_size: 183
#> pin_hash: 02d96ec26791911a
#> type: rds
#> title: 'big-numbers: a pinned integer vector'
#> description: ~
#> tags:
#> - a-single-tag
#> - another-tag
#> created: 20230111T022854Z
#> api_version: 1.0

Created on 2023-01-10 with reprex v2.0.2

NULL values for tags also still work. 👍

Related to #677

@juliasilge juliasilge requested a review from machow January 11, 2023 23:06
@juliasilge
Copy link
Member Author

@machow Want to make sure this is what you were looking for?

Copy link
Collaborator

@machow machow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the wait -- I just tested it out and it LGTM! Thanks for making these changes!

@juliasilge juliasilge merged commit a78db19 into main Jan 21, 2023
@juliasilge juliasilge deleted the tags-to-list branch January 21, 2023 00:56
@github-actions
Copy link

github-actions bot commented Feb 5, 2023

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.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 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

Successfully merging this pull request may close these issues.

2 participants