vetiver_prepare_docker: Generate files necessary to build a Docker container for a...

View source: R/write-docker.R

vetiver_prepare_dockerR Documentation

Generate files necessary to build a Docker container for a vetiver model

Description

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).

Details

The function vetiver_prepare_docker() uses:

  • vetiver_write_plumber() to create a Plumber file and

  • vetiver_write_docker() to create a Dockerfile and renv lockfile

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.

Value

An invisible TRUE.

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)

vetiver_prepare_docker(b, "cars_linear", path = tempdir())


tidymodels/vetiver documentation built on March 25, 2024, 6 p.m.