prepare_docker

prepare_docker(
    board,
    pin_name: str,
    path: str = './',
    version,
    rspm_env: bool = False,
    host: str = '0.0.0.0',
    port: str = '8080',
)

Generate files needed for Docker

Deploying a vetiver model via Docker requires several files. This function will generate a Dockerfile, app.py file, and a requirements.txt to be usedto build and run a Docker container.

Parameters

board :

Pin board for model

pin_name : str

Name of pin

path : Path | str = './'

Path to output

version : str = None

Pin version to be used. If none is supplied, the most recent pin will be selected.

rspm_env : bool = False

Whether or not Posit Package Manager should be used

host : str = '0.0.0.0'

Host address to run VetiverAPI from Dockerfile

port : str = '8080'

Port to run VetiverAPI from Dockerfile

Examples

import vetiver
import tempfile
import pins

tmp = tempfile.TemporaryDirectory()
board = pins.board_temp(allow_pickle_read=True)

X, y = vetiver.get_mock_data()
model = vetiver.get_mock_model().fit(X, y)
v = vetiver.VetiverModel(model, "my_model", prototype_data = X)

vetiver.vetiver_pin_write(board, v)
vetiver.prepare_docker(board = board, pin_name = "my_model", path = tmp.name)

Notes

This function uses vetiver.get_board_pkgs(board) for generating requirements. For more complex use cases, call write_docker(), load_pkgs(), and write_app() individually.