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 '20240318T175925Z-bee31'
#> Writing to pin 'cars_linear'

vetiver_prepare_docker(b, "cars_linear", path = tempdir())
#> The following package(s) will be updated in the lockfile:
#> 
#> # Local ------------------------------------------------------------------
#> - vetiver       [* -> 0.2.5.9000]
#> 
#> # RSPM -------------------------------------------------------------------
#> - R6            [* -> 2.5.1]
#> - Rcpp          [* -> 1.0.12]
#> - askpass       [* -> 1.2.0]
#> - bit           [* -> 4.0.5]
#> - bit64         [* -> 4.0.5]
#> - bundle        [* -> 0.1.1]
#> - butcher       [* -> 0.3.3]
#> - cereal        [* -> 0.1.0]
#> - cli           [* -> 3.6.2]
#> - clipr         [* -> 0.8.0]
#> - cpp11         [* -> 0.4.7]
#> - crayon        [* -> 1.5.2]
#> - curl          [* -> 5.2.1]
#> - digest        [* -> 0.6.35]
#> - ellipsis      [* -> 0.3.2]
#> - fansi         [* -> 1.0.6]
#> - fastmap       [* -> 1.1.1]
#> - fs            [* -> 1.6.3]
#> - generics      [* -> 0.1.3]
#> - glue          [* -> 1.7.0]
#> - hardhat       [* -> 1.3.1]
#> - hms           [* -> 1.1.3]
#> - httpuv        [* -> 1.6.14]
#> - httr          [* -> 1.4.7]
#> - jsonlite      [* -> 1.8.8]
#> - later         [* -> 1.3.2]
#> - lifecycle     [* -> 1.0.4]
#> - lobstr        [* -> 1.1.2]
#> - magrittr      [* -> 2.0.3]
#> - mime          [* -> 0.12]
#> - openssl       [* -> 2.1.1]
#> - pillar        [* -> 1.9.0]
#> - pins          [* -> 1.3.0]
#> - pkgconfig     [* -> 2.0.3]
#> - plumber       [* -> 1.2.1]
#> - prettyunits   [* -> 1.2.0]
#> - progress      [* -> 1.2.3]
#> - promises      [* -> 1.2.1]
#> - purrr         [* -> 1.0.2]
#> - rapidoc       [* -> 9.3.4]
#> - rappdirs      [* -> 0.3.3]
#> - readr         [* -> 2.1.5]
#> - renv          [* -> 1.0.5]
#> - rlang         [* -> 1.1.3]
#> - sodium        [* -> 1.3.1]
#> - stringi       [* -> 1.8.3]
#> - swagger       [* -> 3.33.1]
#> - sys           [* -> 3.4.2]
#> - 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.0]
#> - whisker       [* -> 0.4.1]
#> - withr         [* -> 3.0.0]
#> - yaml          [* -> 2.3.8]
#> 
#> The version of R recorded in the lockfile will be updated:
#> - R             [* -> 4.3.3]
#> 
#> - Lockfile written to "vetiver_renv.lock".