Deployment

Containerization

All processes (including models) in the MISTK ecosystem run as Docker containers and require a Dockerfile to configure the runtime image. The Dockerfile below runs the Logistic Regression model example. It includes the essentials for running within MISTK that can be used for any model, however models are free to add any customizations to their runtime image:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# this model uses a generic python v3.6 base image
FROM python:3.6

# This downloads the latest MISTK wheel file from the Github releases page
# Replace <VERSION> with the latest numbered version (ie. 0.4.0)
RUN wget https://github.com/mistkml/mistk/releases/download/<VERSION>/mistk-<VERSION>-py3-none-any.whl
# Install it via pip
RUN pip install mistk-*-py3-none-any.whl

# this line explicitly installs the model dependencies (optional)
RUN pip install numpy pandas scikit-learn scipy

# install the python code for our Logistic Regression model
RUN mkdir -p /usr/src/models/scikit-basicmodels
COPY . /usr/src/models/scikit-basicmodels
RUN cd /usr/src/models/scikit-basicmodels && python setup.py easy_install -Z .

# these lines set up and run this model using the MISTK infrastructure
EXPOSE 8080
ENTRYPOINT ["python3"]
CMD ["-m", "mistk", "scikit_learn.logistic_regression", "ScikitLearnLogisticRegressionModel"]

The final CMD line starts the model and sets up its endpoints. The third argument (scikit_learn.logistic_regression) is the package/module of our model and the fourth argument (ScikitLearnLogisticRegressionModel) is the model class name.

To update this Dockerfile for a new model, a model developer would update the install path on lines 14-16 and the model path and name on line 21. The MISTK package version denoted by <VERSION> must also be updated on line 6.

The setup.py script referenced above is a standard python setup install script which lists the python package dependencies for the model:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from setuptools import setup, find_packages

REQUIRES=[
'setuptools >= 21.0.0',
'pandas >= 0.20.3',
'scikit-learn >= 0.19.1',
'numpy >= 1.13.3',
'scipy >= 1.0.0',
'mistk'
]

setup(
install_requires=REQUIRES,
name='scikit-basicmodels',
packages=find_packages()
)