Dead code in plumber API
Closed this issue · 2 comments
vetiver_write_api()
creates what appears to be dead code. An example of this can be seen below (derived from Childcare Model screencast).
# Packages needed to generate model predictions
if (FALSE) {
library(parsnip)
library(workflows)
library(xgboost)
}
This code can never be executed unless the user removes the if (FALSE)
statement. What purpose does this code have? Would it better to either delete the if statement or delete it entirely?
Edit: I think I actually understand why it's here now. Is it placed there so that {renv} picks up the appropriate dependencies when used with vetiver_write_docker()
?
Yep, that is on purpose! We add that code when you have rsconnect = TRUE
in vetiver_write_plumber()
to provide the necessary info for Posit Connect automatic package detection.
If you are creating a plumber file for a target other than Posit Connect, you can set rsconnect = FALSE
and these lines will not be included. Notice that this is what happens automatically when you use vetiver_prepare_docker()
:
Line 222 in 4891a5f
Let us know if you have further questions! 🙌