rstudio / pins-r

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

pins 1.0.0 can't read RSConnect pins written by pins 0.4.5 #543

Closed dewoller closed 2 years ago

dewoller commented 3 years ago

The same pin_get command under pins_1.0.0.9000 returns the following error:

pins::board_register_rsconnect(key = Sys.getenv("CONNECT_API_KEY"),
                         server = Sys.getenv("CONNECT_SERVER"))
pins::pin_get("XXXX", board = "rsconnect")

Error: Condition message must be a string

The same error occurs using the new api method:

myboard = pins::board_rsconnect(key = Sys.getenv("CONNECT_API_KEY"),
                         server = Sys.getenv("CONNECT_SERVER"))
pins::pin_get("XXXX", board = myboard)

Error: Condition message must be a string

I would like to be able to use the new package.

dewoller commented 3 years ago

The server is Connecting to RSC 2021.08.0

dewoller commented 3 years ago

pin_read returns the same error:


myboard = pins::board_rsconnect(key = Sys.getenv("CONNECT_API_KEY"),
                         server = Sys.getenv("CONNECT_SERVER"))
pins::pin_read("XXXX", board = myboard)

Error: Condition message must be a string
hadley commented 3 years ago

Can you please provide a traceback?

dewoller commented 3 years ago

Gladly!

> rlang::last_error()
<error/rlang_error>
Condition message must be a string
Backtrace:
  1. pins::pin_get("abc", board = "rsconnect")
  3. pins:::board_pin_get.pins_board_rsconnect(...)
  5. pins:::pin_fetch.pins_board_rsconnect(...)
  7. pins:::pin_meta.pins_board_rsconnect(board, name, version = version)
  8. base::tryCatch(...)
  9. base:::tryCatchList(expr, classes, parentenv, handlers)
 10. base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 11. value[[3L]](cond)
 12. pins:::abort_pin_version_missing(version)
 13. rlang::abort(glue("Can't find version '{version}'"), class = "pins_pin_version_missing")
 14. rlang::error_cnd(...)
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/rlang_error>
Condition message must be a string
Backtrace:
     x
  1. \-pins::pin_get("abc", board = "rsconnect")
  2.   +-pins::board_pin_get(...)
  3.   \-pins:::board_pin_get.pins_board_rsconnect(...)
  4.     +-pins::pin_fetch(board, name, version = version, ...)
  5.     \-pins:::pin_fetch.pins_board_rsconnect(...)
  6.       +-pins::pin_meta(board, name, version = version)
  7.       \-pins:::pin_meta.pins_board_rsconnect(board, name, version = version)
  8.         \-base::tryCatch(...)
  9.           \-base:::tryCatchList(expr, classes, parentenv, handlers)
 10.             \-base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 11.               \-value[[3L]](cond)
 12.                 \-pins:::abort_pin_version_missing(version)
 13.                   \-rlang::abort(glue("Can't find version '{version}'"), class = "pins_pin_version_missing")
 14.                     \-rlang::error_cnd(...)
dewoller commented 3 years ago

Fortunately, the other bug I am having (unable to write a pin with pin_write twice) looks like the same problem. Thanks for the help!

> pin_write(iris, name='abcd', board=board)  ### Writing the pin for the second time
Guessing `type = 'rds'`
Error in rsc_check_status(req) : Forbidden (HTTP 403).
> rlang::last_trace()
<error/rlang_error>
Condition message must be a string
Backtrace:
     x
  1. \-pins::pin_read("abc", board = board)
  2.   +-pins::pin_fetch(board, name, version = version, ...)
  3.   \-pins:::pin_fetch.pins_board_rsconnect(...)
  4.     +-pins::pin_meta(board, name, version = version)
  5.     \-pins:::pin_meta.pins_board_rsconnect(board, name, version = version)
  6.       \-base::tryCatch(...)
  7.         \-base:::tryCatchList(expr, classes, parentenv, handlers)
  8.           \-base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9.             \-value[[3L]](cond)
 10.               \-pins:::abort_pin_version_missing(version)
 11.                 \-rlang::abort(glue("Can't find version '{version}'"), class = "pins_pin_version_missing")
 12.                   \-rlang::error_cnd(...)
>
hadley commented 3 years ago

What does packageVersion("rlang") return?

dewoller commented 3 years ago

Good morning Hadley. Initially, packageVersion("rlang") returned 0.4.5.

When I reinstalled rlang (install.packages('rlang')), packageVersion("rlang") returned 0.4.11, but this did not fix either problem.

dewoller commented 3 years ago

Hi @hadley , I dove into the code, learned a heap about good coding practice, and found part of the problem.

Unfortunately, this particular error message (Error: Condition message must be a string) is a trivial one, due to not initialising version in the _pin_meta.pins_boardrsconnect function. Because I do not pass in a version, when the http process crashes, the error message refers to the null version, not the underlying http failure.

You could fix this by checking for null version in _abort_pin_versionmissing, or by passing in _bundleid instead of version.

Fixing this would help debugging the underlying http errors.

hadley commented 2 years ago

@dewoller sorry for taking so long to get back to this; I see what you mean about the error, and I've at least fixed that so you'll now get a meaningful message. I'll hopefully fix the meat of your problem in the near future.

hadley commented 2 years ago

This works for me:

devtools::install_version("pins", "0.4.5")
library(pins)
board_register_rsconnect(server = "colorado.rstudio.com")
pin(mtcars, "pins-old", board = "rsconnect")

# -------- Restart R ----------

pak::pak("pins")
library(pins)
board <- board_rsconnect(server = "colorado.rstudio.com")
board %>% pin_read("pins-old")
pin_get("pins-old", board = board)

So there must be something else going on.

hadley commented 2 years ago

@dewoller any chance you could try out the dev version in the next couple of days? I'd really like to get a pins release out before Christmas, and I want to double check that I've actually fixed your issue.

dewoller commented 2 years ago

Oh thanks for that Hadley. I greatly appreciate this, and all the nest tending you do around the R ecosystem.

I believe that particular error is fixed. I can read all my pins now. There is one little bug / feature still, but I am not sure if it is intended. I cannot read a pin using pin_get that was written by pin_write.

library(pins)
board =
pins::board_register_rsconnect(key = Sys.getenv("CONNECT_API_KEY"), server = Sys.getenv("CONNECT_SERVER"))
#> Connecting to RSC 2021.11.0 at <XXXX>
iris_small = head(iris, 5 )
pin( board=board, name="dennis.wollersheim@XXXX/abcde", x=iris_small)
pin_get("dennis.wollersheim@XXXX/abcde", board=board)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa
pin_read("dennis.wollersheim@XXXX/abcde", board=board)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa

pin_write( board=board, name="dennis.wollersheim@XXXX/abcde", x=iris_small)
#> Guessing `type = 'rds'`
#> Writing to pin 'dennis.wollersheim@XXXX/dennis.wollersheim@XXXX/abcde'
pin_read("dennis.wollersheim@XXXX/abcde", board=board)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa
pin_get("dennis.wollersheim@XXXX/abcde", board=board)
#> Warning in gzfile(file, "rb"): cannot open compressed file 'C:/Users/
#> dwol3009/AppData/Local/pins/pins/Cache/rsc-e62371cfd77db754024f9c5ed3556a73/
#> c66379b8-57d1-4f99-8f61-d2b9f6d22d62/27131/data.rds', probable reason 'No such
#> file or directory'
#> Error in gzfile(file, "rb"): cannot open the connection

Created on 2021-12-14 by the reprex package (v2.0.1)

hadley commented 2 years ago

Yeah, that's by design — pins is only backward compatible, not forward compatible (i.e. the modern board can read legacy pins, but the legacy board can't read modern pins).

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.