rstudio / pins-r

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

Specifying owner name with pin name in pin_write #613

Closed AYu1804 closed 2 years ago

AYu1804 commented 2 years ago

Hi, our team actively uses this package for pinning data on RSConnect and we often override existing pins with updated versions of them daily/weekly. When we used pins::pin_get and pins::pin that are now legacy, we would pin using the original owner of the pin in the name (e.g. "AYu1804/lookup_pin"). This prevented us from pinning to pins that had the same name as long as the owner was differentiated. With the latest version of the package this isn't possible anymore and if we try to pin_write using the owner's name it will say we are unauthorised. However, using pin_read still works if we specify the owner's name, in fact it seems to be encouraged. Is there a reason why this functionality isn't available in pin_write? Additionally, if a colleague overwrites my pin using pin_write, the suggested code in RSConnect will suggest that the pin is under my colleague's name instead of mine, which is misleading.

machow commented 2 years ago

Hey @AYu1804 -- I tested right now and think I'm able to reproduce. Is the issue that if you write pin_write("<username>/<pin_name>"), that it uses <username> twice? E.g. "<username>/<username>/<pin_name>"?

image
juliasilge commented 2 years ago

I am running into this in vetiver too. I am doing something like pin_write(board, x, name = basename(name_to_use_for_reading)) but that workaround isn't really helpful for this:

This prevented us from pinning to pins that had the same name as long as the owner was differentiated.

AYu1804 commented 2 years ago

Hey @AYu1804 -- I tested right now and think I'm able to reproduce. Is the issue that if you write pin_write("<username>/<pin_name>"), that it uses <username> twice? E.g. "<username>/<username>/<pin_name>"?

image

Yes that's what happens, though using pin_read on "michael.chow/michael.chow/mtcars3" probably wouldn't work and you'd still have to use pin_read(board, "michael.chow/mtcars3"). The issue is more that your colleague can't pin_write using your name as part of the pin name, and even when they overrwrite the pin (without specifying the owner's name), the suggested code on RSConnect would say "colleague.name/mtcars3" which is wrong, you would still need to use pin_read(board, "michael.chow/mtcars3").

juliasilge commented 2 years ago

Related, on our demo server we currently have a pin at michael.chow/mtcars3 and I cannot write a pin of my own with that name.

library(pins)
b <- board_rsconnect()
#> Connecting to RSC 2022.07.0 at <https://colorado.rstudio.com/rsc>
pin_write(b, mtcars, "mtcars3")
#> Guessing `type = 'rds'`
#> Error in `rsc_check_status()` at pins-r/R/board_rsconnect.R:645:2:
#> ! RStudio Connect API failed [403]
#> • You don't have permission to change this item.

Created on 2022-08-12 by the reprex package (v2.0.1)

juliasilge commented 2 years ago

I believe we now have this problem solved via #643, which is merged into main. If you are able to install from GitHub:

remotes::install_github("rstudio/pins-r")

and see if this solves your problems, that would be great!

github-actions[bot] commented 2 years ago

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.