pins-r icon indicating copy to clipboard operation
pins-r copied to clipboard

Pins in RStudio Connect do not show all the metadata available

Open chrisumphlett opened this issue 2 years ago • 22 comments

This stems from an issue I opened at the RStudio community: https://community.rstudio.com/t/how-much-physical-memory-is-my-pin-using/131474/2

https://www.screencast.com/t/V8un8z9xxp shows what I see in RSC for old and new versions of pins.

I want to see the things that one can view with pin_meta(): https://www.screencast.com/t/uTCcWdYjOT

ht to @colearendt

chrisumphlett avatar Apr 11 '22 12:04 chrisumphlett

Hey--can you share some example code for how you were able to pin_write the v1 pin on the left of your screencapture?

AFAIK writing a pin of type table isn't possible, so if I could see how you got it up on RSC, it'd help center in on the problem:

image

machow avatar Apr 12 '22 15:04 machow

Sure. I've never used the type parameter. BTW, this runs in a .Rmd deployed on RSC.

pin(my_data_frame,
    description = "my description",
    board = "rsconnect"
)

chrisumphlett avatar Apr 12 '22 15:04 chrisumphlett

Ah, thanks! If you switch to use pin_write instead...

# need to do...
# board <- board_rsconnect(...)

board %>% pin_write(
    my_data_frame,
    description = "my description",
)

Does it show the preview and file size?

image

machow avatar Apr 12 '22 15:04 machow

Thanks, that did work, with some re-working of my board connection and the parameters in pin_write

board <- board_rsconnect(auth = "manual", key = "my-key", server = "my-server")
pin_write(board,
          dataframe,
          description = "mydesc"
    
)

chrisumphlett avatar Apr 12 '22 15:04 chrisumphlett

@machow I reminded myself of why I had stuck with pin before... this has broken my shiny app that was using the pin. I am having a hard time connecting to it. Problem #1, which I solved: the name of the pin gets switched from using hyphens to underscores. Problem #2, I can successfully connect in my Shiny app when deployed on RSC, but the app running locally gets an error:

Error: [ENOENT] Failed to search directory 'C:/Users/{redacted - some non-sense string}/AppData/Local/pins/pins/Cache/rsc-{redacted string}/{redacted string}': no such file or directory

Why is it searching locally instead of on the RSC board?

chrisumphlett avatar Apr 12 '22 15:04 chrisumphlett

Hey--can you provide code that I could run that reproduces the issue? I wonder if your app is using the old pin retrieval functions--like the deprecated pin_get? If so, maybe changing to pin_read will work?

pin_read should be able to read v0 pins, but I'm not sure it works the other way around

machow avatar Apr 12 '22 16:04 machow

I was already using pin_read()

chrisumphlett avatar Apr 12 '22 17:04 chrisumphlett

I'm not sure about a reprex, given this may be some environment-specific problem I'm having. Here's how I retrieve:

new_df <- pin_read(board, "account/pin-name")

chrisumphlett avatar Apr 12 '22 17:04 chrisumphlett

I'm not sure I'll be able to track the issue down without an example--can you post the traceback? If I could see where in the code raised the error it'd help narrow things down

machow avatar Apr 12 '22 19:04 machow

> traceback()
14: (function (..., call. = TRUE, domain = NULL) 
    {
        if (...length() == 1L && inherits(..1, "condition")) {
            cond <- ..1
            if (nargs() > 1L) 
                warning("additional arguments ignored in stop()")
            message <- conditionMessage(cond)
            call <- conditionCall(cond)
            .Internal(.signalCondition(cond, message, call))
            .Internal(.dfltStop(message, call))
        }
        else .Internal(stop(call., .makeMessage(..., domain = domain)))
    })(structure(list(message = "[ENOENT] Failed to search directory 'C:/Users/{redacted}': no such file or directory"), class = c("ENOENT", 
    "fs_error", "error", "condition"), location = "dir.cc:89"))
13: dir_map(old, identity, all, recurse, type, fail)
12: fs::dir_ls(fs::path(board$cache, guid))
11: rsc_content_version_cached(board, guid)
10: value[[3L]](cond)
9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
8: tryCatchList(expr, classes, parentenv, handlers)
7: tryCatch(rsc_content_version_live(board, guid), error = function(cnd) {
       rsc_content_version_cached(board, guid)
   })
6: rsc_content_version(board, content$guid)
5: pin_meta.pins_board_rsconnect(board, name, version = version)
4: pin_meta(board, name, version = version)
3: pin_fetch.pins_board_rsconnect(board, name, version = version, 
       ...)
2: pin_fetch(board, name, version = version, ...)
1: pin_read(board, "account/pin")

chrisumphlett avatar Apr 13 '22 15:04 chrisumphlett

It looks like you're using board_rsconnect's use_cache_on_failure (which is set to TRUE when using R interactively). I wonder if...

  • it's having issues connecting to RSC, so
  • it falls back to trying your local cache
  • because the content hasn't been accessed (and cached), it errors

It seems like the error message could be a bit more informative 😬. Can you try setting use_cache_on_failure=FALSE in board_rsconnect? I think it might still error, but might make it easier to tell whether it's erroring because it can't connect to your RSC instance

machow avatar Apr 13 '22 15:04 machow

Get this error:

Error: RStudio Connect API failed [404]
* The requested object does not exist.

chrisumphlett avatar Apr 13 '22 18:04 chrisumphlett

Can you post the code that is giving that error? edit: and the full traceback

machow avatar Apr 13 '22 19:04 machow

Here's everything related to reading the pins. The only thing I changed, from what I had before, is indicated with my comments #removed or #added.

library(pins)
httr::set_config(httr::config(ssl_verifypeer = FALSE, ssl_verifyhost = FALSE))
board_server <- if_else(.Platform$OS.type == "windows", "{our RSC url}", "https://{our RSC url}")
pin_rsc_board_key <- Sys.getenv("pin_rsc_board_key")
board <- board_rsconnect(use_cache_on_failure = FALSE) #added
# board <- board_rsconnect(auth = "manual", key = pin_rsc_board_key, server = board_server) #removed
# board_register_rsconnect(                                            #removed
#   account = "my-account",
#   key = Sys.getenv("pin_rsc_board_key"),
#   server = board_server
# )

my-df<- pin_read(board, "my-account/my-pin")

chrisumphlett avatar Apr 14 '22 11:04 chrisumphlett

Can you do things like pin_list(board) etc..?

machow avatar Apr 14 '22 13:04 machow

yes

image

chrisumphlett avatar Apr 14 '22 14:04 chrisumphlett

Hmm.. that's really strange--I wonder if the pin's metadata lists a file that doesn't exist for some reason. What happens if you use pin_meta to get metadata for the pin that caused the 404? If you can post the metadata output, I think we've nearly got things narrowed down......

machow avatar Apr 14 '22 14:04 machow

pin_meta results in the 404 error again. Interesting finding though... it's only one of the pins that I'm using in this app that does this, not both. I deleted it and re-created, same result.

I got it to work by changing pin_meta("account/pin-name") to pin_meta("pin-name"). Of course, it yells at me about not using the full name when I do that... pin_read() works the same way now as well.

chrisumphlett avatar Apr 14 '22 14:04 chrisumphlett

If you pin_write and pin_read using a different name for the pin, does it work? I wonder if one thing that could help is deleting your board$cache folder (you may need to run board_rsconnect again after that).

Here's the output I see for my rsc cache:

> board$cache
~/Library/Caches/pins/rsc-e62371cfd77db754024f9c5ed3556a73

(cc @colearendt , in case you've seen something like this?)

machow avatar Apr 14 '22 14:04 machow

Yea just adding a '2' to the name of the pin and it works with the full reference to the pin name. Manually deleting the cache folder, and now I can use the original (full) name. Thanks for that suggestion

chrisumphlett avatar Apr 14 '22 16:04 chrisumphlett

Ah, glad it's working! One last thing to check if it's okay--did you change your username, or did someone else originally own the pin content? I wonder if this was related to...

  • https://github.com/rstudio/pins/issues/594

machow avatar Apr 14 '22 16:04 machow

no intentional changes, I am the only one who has written the pin. I had to change my password recently (we use SSO with RSC) which caused various kinds of havoc, that's the only kind of change I can think of.

chrisumphlett avatar Apr 14 '22 16:04 chrisumphlett

I believe we have made improvements in #643 and #667 that will avoid getting into this bad state. Please let us know if you have further problems! 🙌

juliasilge avatar Nov 04 '22 16:11 juliasilge

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[bot] avatar Nov 19 '22 00:11 github-actions[bot]