write_docker

write_docker

Functions

Name Description
prepare_docker Create all files needed for Docker
write_docker Writes a Dockerfile to run VetiverAPI in a container

prepare_docker

write_docker.prepare_docker(board, pin_name, path='./', version=None, rspm_env=False, host='0.0.0.0', port='8080')

Create all files needed for Docker

Parameters

Name Type Description Default
board Pin board for model required
pin_name str Name of pin required
path str Path to output './'
version Pin version to be used None
rspm_env bool Whether or not Posit Package Manager should be used False
host str Host address to run VetiverAPI from Dockerfile '0.0.0.0'
port str Port to run VetiverAPI from Dockerfile '8080'

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.

write_docker

write_docker.write_docker(app_file='app.py', path='./', rspm_env=False, host='0.0.0.0', port='8080')

Writes a Dockerfile to run VetiverAPI in a container

Parameters

Name Type Description Default
app_file str File containing VetiverAPI to be deployed into container 'app.py'
path str Path to save Dockerfile './'
rspm_env bool Whether or not Posit Package Manager should be used False
host str Host address to run VetiverAPI from Dockerfile '0.0.0.0'
port str Port to run VetiverAPI from Dockerfile '8080'

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.write_app(board,
...     "my_model",
...     file = tmp.name + "/app.py") # need file for model
>>> vetiver.write_docker(app_file = "app.py", path = tmp.name)