rstudio / vetiver-r

Version, share, deploy, and monitor models
https://rstudio.github.io/vetiver-r/
Other
184 stars 28 forks source link

Use base R `deparse()` when writing `plumber.R` #241

Closed juliasilge closed 1 year ago

juliasilge commented 1 year ago

Closes #239

With this change, I now can correctly generate code for a board_url().

library(pins)
b <- board_url(c(
  chicago_model = 'https://colorado.posit.co/rsc/chicago-rstats-model-pin/'
))

deparse(board_deparse(b))
#> [1] "board_url(c(chicago_model = \"https://colorado.posit.co/rsc/chicago-rstats-model-pin/\"))"

Created on 2023-09-07 with reprex v2.0.2

juliasilge commented 1 year ago

The tests all pass still, and I just made a plumber.R that looks like this:

# Generated by the vetiver package; edit with care

library(pins)
library(plumber)
library(rapidoc)
library(vetiver)
b <- board_url(c(chicago_model = "https://colorado.posit.co/rsc/chicago-rstats-model-pin/"))
v <- vetiver_pin_read(b, "chicago_model")

#* @plumber
function(pr) {
    pr %>% vetiver_api(v)
}