rstudio / pins-r

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

The code chunk from RStudio Connect doesn't work without modifications #603

Closed scherbakovdmitri closed 2 years ago

scherbakovdmitri commented 2 years ago

Hello, If I run this code in RStudio:

library(pins)
board <- board_rsconnect()
mtcars <- tibble::as_tibble(mtcars)
board %>% pin_write(mtcars, "mtcars")

And then open the pin in Connect , it shows this chunk of code:

library(pins)
board <- board_rsconnect("envvar", server = "http://10.0.0.15")
pin_read(board, "subsea/mtcars")

If I run it I get this:

> board <- board_rsconnect("envvar", server = "http://10.0.0.15")
Error in `rsc_server()`:
! Can't find CONNECT_API_KEY env var

The chunk that works is this:

library(pins)
board <- board_rsconnect(server = "10.0.0.15")
pin_read(board, "subsea/mtcars")

Wouldn't it be better to display this one instead? Because if sharing with other users, they can get confused if they see some chunk in Connect which doesn't work right away.

juliasilge commented 2 years ago

Given how board_rsconnect() works, I wonder if showing board <- board_rsconnect() would work for more people. This preview is being created using board_deparse():

library(pins)
b <- board_rsconnect()
#> Connecting to RSC 2022.07.0 at <https://colorado.rstudio.com/rsc>
board_deparse(b)
#> board_rsconnect("envvar", server = "https://colorado.rstudio.com/rsc")

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

We chose "envvar" here because it is most likely to be used in non-interactive contexts (like for vetiver) and it is what we recommend for all users in Connect documentation. Thoughts?

juliasilge commented 2 years ago

Thank you for your discussion! 🙌 For now, let's keep displaying the code that aligns with what we recommend for all users on Connect.

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.