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

Pins in RStudio Connect do not show all the metadata available #609

Closed
chrisumphlett opened this issue Apr 11, 2022 · 24 comments
Closed

Pins in RStudio Connect do not show all the metadata available #609

chrisumphlett opened this issue Apr 11, 2022 · 24 comments

Comments

@chrisumphlett
Copy link

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

@machow
Copy link
Collaborator

machow commented Apr 12, 2022

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

@chrisumphlett
Copy link
Author

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"
)

@machow
Copy link
Collaborator

machow commented Apr 12, 2022

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

@chrisumphlett
Copy link
Author

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
Copy link
Author

@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?

@machow
Copy link
Collaborator

machow commented Apr 12, 2022

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

@chrisumphlett
Copy link
Author

I was already using pin_read()

@chrisumphlett
Copy link
Author

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")

@machow
Copy link
Collaborator

machow commented Apr 12, 2022

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

@chrisumphlett
Copy link
Author

> 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")

@machow
Copy link
Collaborator

machow commented Apr 13, 2022

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

@chrisumphlett
Copy link
Author

Get this error:

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

@machow
Copy link
Collaborator

machow commented Apr 13, 2022

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

@chrisumphlett
Copy link
Author

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")

@machow
Copy link
Collaborator

machow commented Apr 14, 2022

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

@chrisumphlett
Copy link
Author

yes

image

@machow
Copy link
Collaborator

machow commented Apr 14, 2022

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......

@chrisumphlett
Copy link
Author

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.

@machow
Copy link
Collaborator

machow commented Apr 14, 2022

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?)

@chrisumphlett
Copy link
Author

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

@machow
Copy link
Collaborator

machow commented Apr 14, 2022

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...

@chrisumphlett
Copy link
Author

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.

@juliasilge
Copy link
Member

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! 🙌

@github-actions
Copy link

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 github-actions bot locked and limited conversation to collaborators Nov 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants