Skip to content

Deploying a vetiver model via Docker requires several files. Use this function to create these needed files in the directory located at path.

Usage

vetiver_prepare_docker(
  board,
  name,
  version = NULL,
  path = ".",
  predict_args = list(),
  docker_args = list()
)

Arguments

board

A pin board, created by board_folder(), board_connect(), board_url() or another board_ function.

name

Pin name.

version

Retrieve a specific version of a pin. Use pin_versions() to find out which versions are available and when they were created.

path

A path to write the Plumber file, Dockerfile, and lockfile, capturing the model's dependencies.

predict_args

A list of optional arguments passed to vetiver_api() such as the prediction type.

docker_args

A list of optional arguments passed to vetiver_write_docker() such as the lockfile name or whether to use rspm. Do not pass additional_pkgs here, as this function uses additional_pkgs = required_pkgs(board).

Value

An invisible TRUE.

Details

The function vetiver_prepare_docker() uses:

These modular functions are available for more advanced use cases. For models such as keras and torch, you will need to edit the generated Dockerfile to, for example, COPY requirements.txt requirements.txt or similar.

Examples

library(pins)
b <- board_temp(versioned = TRUE)
cars_lm <- lm(mpg ~ ., data = mtcars)
v <- vetiver_model(cars_lm, "cars_linear")
vetiver_pin_write(b, v)
#> Creating new version '20241009T170845Z-7301a'
#> Writing to pin 'cars_linear'

vetiver_prepare_docker(b, "cars_linear", path = tempdir())
#> The following required packages are not installed:
#> - cpp11  [required by lobstr, readr, tzdb, and 1 other]
#> Consider reinstalling these packages before snapshotting the lockfile.
#> 
#> The following package(s) will be updated in the lockfile:
#> 
#> # Local ------------------------------------------------------------------
#> - vetiver       [* -> 0.2.5.9000]
#> 
#> # RSPM -------------------------------------------------------------------
#> - R6            [* -> 2.5.1]
#> - Rcpp          [* -> 1.0.13]
#> - askpass       [* -> 1.2.1]
#> - bit           [* -> 4.5.0]
#> - bit64         [* -> 4.5.2]
#> - bundle        [* -> 0.1.1]
#> - butcher       [* -> 0.3.4]
#> - cereal        [* -> 0.1.0]
#> - cli           [* -> 3.6.3]
#> - clipr         [* -> 0.8.0]
#> - crayon        [* -> 1.5.3]
#> - curl          [* -> 5.2.3]
#> - digest        [* -> 0.6.37]
#> - ellipsis      [* -> 0.3.2]
#> - fansi         [* -> 1.0.6]
#> - fastmap       [* -> 1.2.0]
#> - fs            [* -> 1.6.4]
#> - generics      [* -> 0.1.3]
#> - glue          [* -> 1.8.0]
#> - hardhat       [* -> 1.4.0]
#> - hms           [* -> 1.1.3]
#> - httpuv        [* -> 1.6.15]
#> - httr          [* -> 1.4.7]
#> - jsonlite      [* -> 1.8.9]
#> - later         [* -> 1.3.2]
#> - lifecycle     [* -> 1.0.4]
#> - lobstr        [* -> 1.1.2]
#> - magrittr      [* -> 2.0.3]
#> - mime          [* -> 0.12]
#> - openssl       [* -> 2.2.2]
#> - pillar        [* -> 1.9.0]
#> - pins          [* -> 1.4.0]
#> - pkgconfig     [* -> 2.0.3]
#> - plumber       [* -> 1.2.2]
#> - prettyunits   [* -> 1.2.0]
#> - progress      [* -> 1.2.3]
#> - promises      [* -> 1.3.0]
#> - purrr         [* -> 1.0.2]
#> - rapidoc       [* -> 9.3.4]
#> - rappdirs      [* -> 0.3.3]
#> - readr         [* -> 2.1.5]
#> - renv          [* -> 1.0.10]
#> - rlang         [* -> 1.1.4]
#> - sodium        [* -> 1.3.2]
#> - stringi       [* -> 1.8.4]
#> - swagger       [* -> 5.17.14.1]
#> - sys           [* -> 3.4.3]
#> - tibble        [* -> 3.2.1]
#> - tidyselect    [* -> 1.2.1]
#> - tzdb          [* -> 0.4.0]
#> - utf8          [* -> 1.2.4]
#> - vctrs         [* -> 0.6.5]
#> - vroom         [* -> 1.6.5]
#> - webutils      [* -> 1.2.2]
#> - whisker       [* -> 0.4.1]
#> - withr         [* -> 3.0.1]
#> - yaml          [* -> 2.3.10]
#> 
#> The version of R recorded in the lockfile will be updated:
#> - R             [* -> 4.4.1]
#> 
#> - Lockfile written to "vetiver_renv.lock".