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

Move to new generic scheme #50

Merged
merged 8 commits into from Oct 25, 2021
Merged

Move to new generic scheme #50

merged 8 commits into from Oct 25, 2021

Conversation

juliasilge
Copy link
Member

This new generic scheme involves vetiver_model() being a plain function and instead the developer needing to write six 6️⃣ methods:

  • four for creating the model object (two of these are "maybe" but the person needs to think through them)
  • two for the API handlers

This is three more methods than before, but we have it more explicitly broken out by task.

@juliasilge
Copy link
Member Author

This works out pretty well for xgboost:

library(vetiver)
library(pins)
library(plumber)

model_board <- board_folder(path = "/tmp/test", versioned = TRUE)
car_xgb <- xgboost::xgboost(as.matrix(mtcars[,-1]), 
                            mtcars$mpg, 
                            nrounds = 3, 
                            objective = "reg:squarederror")
#> [1]  train-rmse:14.931315 
#> [2]  train-rmse:10.956807 
#> [3]  train-rmse:8.086657
v <- vetiver_model(car_xgb, "cars_xgb", model_board)
vetiver_pin_write(v)
#> Creating new version '20211021T223836Z-11cd9'
#> Writing to pin 'cars_xgb'

pr() %>%
    vetiver_pr_predict(v, debug = TRUE)
#> # Plumber router with 1 endpoint, 4 filters, and 0 sub-routers.
#> # Use `pr_run()` on this object to start the API.
#> ├──[queryString]
#> ├──[body]
#> ├──[cookieParser]
#> ├──[sharedSecret]
#> └──/predict (POST)
 ## next pipe to pr_run(port = 8088) to see visual documentation

Created on 2021-10-21 by the reprex package (v2.0.1)

@juliasilge juliasilge changed the title Try out new generic scheme Move to new generic scheme Oct 25, 2021
@juliasilge juliasilge merged commit 1f2a216 into master Oct 25, 2021
@juliasilge juliasilge deleted the try-new-generics branch October 25, 2021 18:51
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

Successfully merging this pull request may close these issues.

None yet

1 participant