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

Find a better solution for generating code in vetiver_write_plumber() #274

Open
juliasilge opened this issue Mar 1, 2024 · 0 comments
Open

Comments

@juliasilge
Copy link
Member

juliasilge commented Mar 1, 2024

As of right now, we use this approach to generating the code to read a board in vetiver_write_plumber():

## rlang::expr_deparse won't work for board_url, but
## base deparse won't work for S3 and other complex boards:
if (inherits(board, "pins_board_url")) {
board <- deparse(pins::board_deparse(board))
} else {
board <- rlang::expr_deparse(pins::board_deparse(board))
}

Problems around this have come up multiple times, in #253, #256, and #239, but we still are not in a good place. @EmilHvitfeldt reported yet another problem, when the code needed for board_*() is so long that the width option makes it break across lines.

What is a good way to solve this once and for all?

  • Is there something like deparse() or rlang::expr_deparse() that lets us never print across multiple lines?
  • Just set width to something really big?
  • Can we get the numbers of characters from pins::board_deparse(board) and then set the width in rlang::expr_deparse()? (Note, it's not a character.) Like sum(nchar(as.character(board_deparse(board)))) and then add in another couple dozen characters to account for how the call is structured?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant