BentoML makes moving trained ML models to production easy:
BentoML is a framework for serving, managing, and deploying machine learning models. It is aiming to bridge the gap between Data Science and DevOps, and enable teams to deliver prediction services in a fast, repeatable, and scalable way.
Before reading this example project, be sure to check out the Getting started guide to learn about the basic concepts in BentoML.
This is a BentoML Demo Project demonstrating how to train a League of Legend win prdiction model, and use BentoML to package and serve the model for building applictions.
Example notebook built based on https://slundberg.github.io/shap/notebooks/League%20of%20Legends%20Win%20Prediction%20with%20XGBoost.html
%reload_ext autoreload
%autoreload 2
%matplotlib inline
import warnings
warnings.filterwarnings("ignore")
!pip install -q bentoml "numpy>=1.18.5" "xgboost==0.90" "scikit-learn>=0.23.0" "matplotlib>=3.2.2" "kaggle==1.5.6"
Requirement already satisfied: bentoml in /opt/anaconda3/lib/python3.7/site-packages (0.8.1+27.g8e155f5.dirty) Requirement already satisfied: requests in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (2.24.0) Requirement already satisfied: click>=7.0 in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (7.1.2) Requirement already satisfied: alembic in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (1.4.0) Requirement already satisfied: cerberus in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (1.3.2) Requirement already satisfied: prometheus-client in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (0.8.0) Requirement already satisfied: protobuf>=3.6.0 in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (3.11.3) Requirement already satisfied: aiohttp in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (3.6.2) Requirement already satisfied: sqlalchemy-utils in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (0.36.6) Requirement already satisfied: ruamel.yaml>=0.15.0 in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (0.16.10) Requirement already satisfied: tabulate in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (0.8.6) Requirement already satisfied: humanfriendly in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (7.1.1) Requirement already satisfied: numpy in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (1.18.5) Requirement already satisfied: packaging in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (20.4) Requirement already satisfied: psutil in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (5.7.0) Requirement already satisfied: configparser in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (4.0.2) Requirement already satisfied: certifi in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (2020.6.20) Requirement already satisfied: grpcio<=1.27.2 in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (1.27.2) Requirement already satisfied: flask in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (1.1.1) Requirement already satisfied: sqlalchemy>=1.3.0 in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (1.3.9) Requirement already satisfied: python-json-logger in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (0.1.11) Requirement already satisfied: py-zipkin in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (0.18.7) Requirement already satisfied: python-dateutil<2.8.1,>=2.1 in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (2.8.0) Requirement already satisfied: gunicorn in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (20.0.4) Requirement already satisfied: docker in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (4.2.0) Requirement already satisfied: boto3 in /opt/anaconda3/lib/python3.7/site-packages (from bentoml) (1.12.9) Requirement already satisfied: chardet<4,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests->bentoml) (3.0.4) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests->bentoml) (1.24.3) Requirement already satisfied: idna<3,>=2.5 in /opt/anaconda3/lib/python3.7/site-packages (from requests->bentoml) (2.10) Requirement already satisfied: python-editor>=0.3 in /opt/anaconda3/lib/python3.7/site-packages (from alembic->bentoml) (1.0.4) Requirement already satisfied: Mako in /opt/anaconda3/lib/python3.7/site-packages (from alembic->bentoml) (1.1.1) Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from cerberus->bentoml) (49.1.0.post20200710) Requirement already satisfied: six>=1.9 in /opt/anaconda3/lib/python3.7/site-packages (from protobuf>=3.6.0->bentoml) (1.15.0) Requirement already satisfied: attrs>=17.3.0 in /opt/anaconda3/lib/python3.7/site-packages (from aiohttp->bentoml) (19.3.0) Requirement already satisfied: yarl<2.0,>=1.0 in /opt/anaconda3/lib/python3.7/site-packages (from aiohttp->bentoml) (1.4.2) Requirement already satisfied: multidict<5.0,>=4.5 in /opt/anaconda3/lib/python3.7/site-packages (from aiohttp->bentoml) (4.7.5) Requirement already satisfied: async-timeout<4.0,>=3.0 in /opt/anaconda3/lib/python3.7/site-packages (from aiohttp->bentoml) (3.0.1) Requirement already satisfied: ruamel.yaml.clib>=0.1.2; platform_python_implementation == "CPython" and python_version < "3.9" in /opt/anaconda3/lib/python3.7/site-packages (from ruamel.yaml>=0.15.0->bentoml) (0.2.0) Requirement already satisfied: pyparsing>=2.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from packaging->bentoml) (2.4.7) Requirement already satisfied: Jinja2>=2.10.1 in /opt/anaconda3/lib/python3.7/site-packages (from flask->bentoml) (2.11.2) Requirement already satisfied: Werkzeug>=0.15 in /opt/anaconda3/lib/python3.7/site-packages (from flask->bentoml) (0.16.0) Requirement already satisfied: itsdangerous>=0.24 in /opt/anaconda3/lib/python3.7/site-packages (from flask->bentoml) (1.1.0) Requirement already satisfied: thriftpy2>=0.4.0 in /opt/anaconda3/lib/python3.7/site-packages (from py-zipkin->bentoml) (0.4.10) Requirement already satisfied: websocket-client>=0.32.0 in /opt/anaconda3/lib/python3.7/site-packages (from docker->bentoml) (0.57.0) Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in /opt/anaconda3/lib/python3.7/site-packages (from boto3->bentoml) (0.3.3) Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /opt/anaconda3/lib/python3.7/site-packages (from boto3->bentoml) (0.9.5) Requirement already satisfied: botocore<1.16.0,>=1.15.9 in /opt/anaconda3/lib/python3.7/site-packages (from boto3->bentoml) (1.15.9) Requirement already satisfied: MarkupSafe>=0.9.2 in /opt/anaconda3/lib/python3.7/site-packages (from Mako->alembic->bentoml) (1.1.1) Requirement already satisfied: ply<4.0,>=3.4 in /opt/anaconda3/lib/python3.7/site-packages (from thriftpy2>=0.4.0->py-zipkin->bentoml) (3.11) Requirement already satisfied: docutils<0.16,>=0.10 in /opt/anaconda3/lib/python3.7/site-packages (from botocore<1.16.0,>=1.15.9->boto3->bentoml) (0.15.2) Requirement already satisfied: numpy in /opt/anaconda3/lib/python3.7/site-packages (1.18.5) Requirement already satisfied: xgboost in /opt/anaconda3/lib/python3.7/site-packages (0.90) Requirement already satisfied: sklearn in /opt/anaconda3/lib/python3.7/site-packages (0.0) Requirement already satisfied: matplotlib in /opt/anaconda3/lib/python3.7/site-packages (3.2.2) Requirement already satisfied: kaggle in /opt/anaconda3/lib/python3.7/site-packages (1.5.6) Requirement already satisfied: scipy in /opt/anaconda3/lib/python3.7/site-packages (from xgboost) (1.3.1) Requirement already satisfied: scikit-learn in /opt/anaconda3/lib/python3.7/site-packages (from sklearn) (0.21.3) Requirement already satisfied: cycler>=0.10 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib) (0.10.0) Requirement already satisfied: python-dateutil>=2.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib) (2.8.0) Requirement already satisfied: kiwisolver>=1.0.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib) (1.1.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib) (2.4.7) Requirement already satisfied: urllib3<1.25,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from kaggle) (1.24.3) Requirement already satisfied: requests in /opt/anaconda3/lib/python3.7/site-packages (from kaggle) (2.24.0) Requirement already satisfied: six>=1.10 in /opt/anaconda3/lib/python3.7/site-packages (from kaggle) (1.15.0) Requirement already satisfied: python-slugify in /opt/anaconda3/lib/python3.7/site-packages (from kaggle) (4.0.1) Requirement already satisfied: tqdm in /home/bentoml/.local/lib/python3.7/site-packages (from kaggle) (4.45.0) Requirement already satisfied: certifi in /opt/anaconda3/lib/python3.7/site-packages (from kaggle) (2020.6.20) Requirement already satisfied: joblib>=0.11 in /opt/anaconda3/lib/python3.7/site-packages (from scikit-learn->sklearn) (0.13.2) Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib) (49.1.0.post20200710) Requirement already satisfied: idna<3,>=2.5 in /opt/anaconda3/lib/python3.7/site-packages (from requests->kaggle) (2.10) Requirement already satisfied: chardet<4,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests->kaggle) (3.0.4) Requirement already satisfied: text-unidecode>=1.3 in /opt/anaconda3/lib/python3.7/site-packages (from python-slugify->kaggle) (1.3)
import pandas as pd
import numpy as np
import xgboost as xgb
import matplotlib.pyplot as pl
from sklearn.model_selection import train_test_split
This notebook uses data from kaggle paololol/league-of-legends-ranked-matches
You can set your Kaggle credential below and download the dataset automatically. The kaggle key can be created by going to the 'Account' tab of your user profile (https://www.kaggle.com/
Alternativelly, you can download it manually from here and place unzip'd data in this folder.
%%bash
export KAGGLE_USERNAME=
export KAGGLE_KEY=
if [ ! -f ./league-of-legends-ranked-matches.zip ]; then
kaggle datasets download paololol/league-of-legends-ranked-matches
unzip -n league-of-legends-ranked-matches.zip
fi
# read in the data
matches = pd.read_csv("matches.csv")
participants = pd.read_csv("participants.csv")
stats1 = pd.read_csv("stats1.csv", low_memory=False)
stats2 = pd.read_csv("stats2.csv", low_memory=False)
stats = pd.concat([stats1,stats2])
# merge into a single DataFrame
a = pd.merge(participants, matches, left_on="matchid", right_on="id")
allstats_orig = pd.merge(a, stats, left_on="matchid", right_on="id")
allstats = allstats_orig.copy()
# drop games that lasted less than 10 minutes
allstats = allstats.loc[allstats["duration"] >= 10*60,:]
# Convert string-based categories to numeric values
cat_cols = ["role", "position", "version", "platformid"]
for c in cat_cols:
allstats[c] = allstats[c].astype('category')
allstats[c] = allstats[c].cat.codes
allstats["wardsbought"] = allstats["wardsbought"].astype(np.int32)
X = allstats.drop(["win"], axis=1)
y = allstats["win"]
# convert all features we want to consider as rates
rate_features = [
"kills", "deaths", "assists", "killingsprees", "doublekills",
"triplekills", "quadrakills", "pentakills", "legendarykills",
"totdmgdealt", "magicdmgdealt", "physicaldmgdealt", "truedmgdealt",
"totdmgtochamp", "magicdmgtochamp", "physdmgtochamp", "truedmgtochamp",
"totheal", "totunitshealed", "dmgtoobj", "timecc", "totdmgtaken",
"magicdmgtaken" , "physdmgtaken", "truedmgtaken", "goldearned", "goldspent",
"totminionskilled", "neutralminionskilled", "ownjunglekills",
"enemyjunglekills", "totcctimedealt", "pinksbought", "wardsbought",
"wardsplaced", "wardskilled"
]
for feature_name in rate_features:
X[feature_name] /= X["duration"] / 60 # per minute rate
# convert to fraction of game
X["longesttimespentliving"] /= X["duration"]
# define friendly names for the features
full_names = {
"kills": "Kills per min.",
"deaths": "Deaths per min.",
"assists": "Assists per min.",
"killingsprees": "Killing sprees per min.",
"longesttimespentliving": "Longest time living as % of game",
"doublekills": "Double kills per min.",
"triplekills": "Triple kills per min.",
"quadrakills": "Quadra kills per min.",
"pentakills": "Penta kills per min.",
"legendarykills": "Legendary kills per min.",
"totdmgdealt": "Total damage dealt per min.",
"magicdmgdealt": "Magic damage dealt per min.",
"physicaldmgdealt": "Physical damage dealt per min.",
"truedmgdealt": "True damage dealt per min.",
"totdmgtochamp": "Total damage to champions per min.",
"magicdmgtochamp": "Magic damage to champions per min.",
"physdmgtochamp": "Physical damage to champions per min.",
"truedmgtochamp": "True damage to champions per min.",
"totheal": "Total healing per min.",
"totunitshealed": "Total units healed per min.",
"dmgtoobj": "Damage to objects per min.",
"timecc": "Time spent with crown control per min.",
"totdmgtaken": "Total damage taken per min.",
"magicdmgtaken": "Magic damage taken per min.",
"physdmgtaken": "Physical damage taken per min.",
"truedmgtaken": "True damage taken per min.",
"goldearned": "Gold earned per min.",
"goldspent": "Gold spent per min.",
"totminionskilled": "Total minions killed per min.",
"neutralminionskilled": "Neutral minions killed per min.",
"ownjunglekills": "Own jungle kills per min.",
"enemyjunglekills": "Enemy jungle kills per min.",
"totcctimedealt": "Total crown control time dealt per min.",
"pinksbought": "Pink wards bought per min.",
"wardsbought": "Wards bought per min.",
"wardsplaced": "Wards placed per min.",
"turretkills": "# of turret kills",
"inhibkills": "# of inhibitor kills",
"dmgtoturrets": "Damage to turrets"
}
feature_names = [full_names.get(n, n) for n in X.columns]
X.columns = feature_names
# create train/validation split
Xt, Xv, yt, yv = train_test_split(X,y, test_size=0.2, random_state=10)
dt = xgb.DMatrix(Xt, label=yt.values)
dv = xgb.DMatrix(Xv, label=yv.values)
params = {
"eta": 0.5,
"max_depth": 4,
"objective": "binary:logistic",
"silent": 1,
"base_score": np.mean(yt),
"eval_metric": "logloss"
}
model = xgb.train(params, dt, 100, [(dt, "train"),(dv, "valid")], early_stopping_rounds=5, verbose_eval=10)
[15:31:01] WARNING: /Users/travis/build/dmlc/xgboost/src/learner.cc:516: Parameters: { silent } might not be used. This may not be accurate due to some parameters are only used in language bindings but passed down to XGBoost core. Or some parameters are not used but slip through this verification. Please open an issue if you find above cases. [0] train-logloss:0.54119 valid-logloss:0.54137 Multiple eval metrics have been passed: 'valid-logloss' will be used for early stopping. Will train until valid-logloss hasn't improved in 5 rounds. [10] train-logloss:0.34090 valid-logloss:0.34078 [20] train-logloss:0.29880 valid-logloss:0.29892 [30] train-logloss:0.27532 valid-logloss:0.27589 [40] train-logloss:0.26305 valid-logloss:0.26410 [50] train-logloss:0.25208 valid-logloss:0.25362 [60] train-logloss:0.24394 valid-logloss:0.24587 [70] train-logloss:0.23717 valid-logloss:0.23933 [80] train-logloss:0.23103 valid-logloss:0.23352 [90] train-logloss:0.22614 valid-logloss:0.22881 [99] train-logloss:0.22185 valid-logloss:0.22484
Xt[:3]
id_x | matchid | player | championid | ss1 | ss2 | role | position | id_y | gameid | ... | Neutral minions killed per min. | Own jungle kills per min. | Enemy jungle kills per min. | Total crown control time dealt per min. | champlvl | Pink wards bought per min. | Wards bought per min. | Wards placed per min. | wardskilled | firstblood | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1215555 | 1501034 | 150933 | 10 | 59 | 4 | 11 | 2 | 2 | 150933 | 3162804935 | ... | 0.023086 | 0.023086 | 0.000000 | 7.572143 | 18 | 0.069257 | 0.0 | 0.831089 | 0.253944 | 0 |
1427835 | 1713614 | 172357 | 6 | 35 | 11 | 14 | 3 | 1 | 172357 | 3186087472 | ... | 0.028262 | 0.028262 | 0.000000 | 10.937353 | 16 | 0.000000 | 0.0 | 0.197833 | 0.000000 | 0 |
1204118 | 1489597 | 149786 | 3 | 34 | 4 | 14 | 4 | 2 | 149786 | 3193266242 | ... | 0.882817 | 0.693642 | 0.189175 | 11.192853 | 18 | 0.063058 | 0.0 | 0.567525 | 0.189175 | 0 |
3 rows × 71 columns
model.predict(xgb.DMatrix(Xt[:3]))
array([0.35312122, 0.06715239, 0.04428952], dtype=float32)
%%writefile lol_win_predictions.py
from bentoml import api, env, BentoService, artifacts
from bentoml.frameworks.xgboost import XgboostModelArtifact
from bentoml.adapters import DataframeInput
import xgboost as xgb
@env(pip_packages=['xgboost'])
@artifacts([XgboostModelArtifact('model')])
class LeagueWinPrediction(BentoService):
@api(input=DataframeInput(), batch=True)
def predict(self, df):
dmatrix = xgb.DMatrix(df)
return self.artifacts.model.predict(dmatrix)
Overwriting lol_win_predictions.py
# 1) import the custom BentoService defined above
from lol_win_predictions import LeagueWinPrediction
# 2) `pack` it with required artifacts
bento_svc = LeagueWinPrediction()
bento_svc.pack('model', model)
# 3) save your BentoSerivce
saved_path = bento_svc.save()
[2020-09-22 15:36:13,398] WARNING - Using BentoML installed in `editable` model, the local BentoML repository including all code changes will be packaged together with saved bundle created, under the './bundled_pip_dependencies' directory of the saved bundle. [2020-09-22 15:36:13,853] INFO - Using default docker base image: `None` specified inBentoML config file or env var. User must make sure that the docker base image either has Python 3.7 or conda installed. [2020-09-22 15:36:13,856] WARNING - pip package requirement xgboost already exist [2020-09-22 15:36:14,960] INFO - Detected non-PyPI-released BentoML installed, copying local BentoML modulefiles to target saved bundle path..
warning: no previously-included files matching '*~' found anywhere in distribution warning: no previously-included files matching '*.pyo' found anywhere in distribution warning: no previously-included files matching '.git' found anywhere in distribution warning: no previously-included files matching '.ipynb_checkpoints' found anywhere in distribution warning: no previously-included files matching '__pycache__' found anywhere in distribution no previously-included directories found matching 'e2e_tests' no previously-included directories found matching 'tests' no previously-included directories found matching 'benchmark'
UPDATING BentoML-0.9.0rc0+3.gcebf2015/bentoml/_version.py set BentoML-0.9.0rc0+3.gcebf2015/bentoml/_version.py to '0.9.0.pre+3.gcebf2015' [2020-09-22 15:36:19,116] INFO - BentoService bundle 'LeagueWinPrediction:20200922153614_15BE7D' saved to: /Users/bozhaoyu/bentoml/repository/LeagueWinPrediction/20200922153614_15BE7D
To start a REST API model server with the BentoService saved above, use the bentoml serve command:
!bentoml serve LeagueWinPrediction:latest
[2020-09-22 15:36:38,016] INFO - Getting latest version LeagueWinPrediction:20200922153614_15BE7D [2020-09-22 15:36:38,017] INFO - Starting BentoML API server in development mode.. [2020-09-22 15:36:38,363] WARNING - Using BentoML installed in `editable` model, the local BentoML repository including all code changes will be packaged together with saved bundle created, under the './bundled_pip_dependencies' directory of the saved bundle. [2020-09-22 15:36:38,379] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015 [2020-09-22 15:36:40,823] INFO - Using default docker base image: `None` specified inBentoML config file or env var. User must make sure that the docker base image either has Python 3.7 or conda installed. [2020-09-22 15:36:40,825] WARNING - pip package requirement xgboost already exist * Serving Flask app "LeagueWinPrediction" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) 127.0.0.1 - - [22/Sep/2020 15:37:09] "POST /predict HTTP/1.1" 400 - WARNING: Logging before flag parsing goes to stderr. I0922 15:37:09.624686 4628762048 _internal.py:122] 127.0.0.1 - - [22/Sep/2020 15:37:09] "POST /predict HTTP/1.1" 400 - ^C
If you are running this notebook from Google Colab, you can start the dev server with --run-with-ngrok
option, to gain acccess to the API endpoint via a public endpoint managed by ngrok:
!bentoml serve LeagueWinPrediction:latest --run-with-ngrok
After navigate to the location of this notebook, copy and paste the following code to your terminal and run it to make request
curl -i \
--request POST \
--header "Content-Type: text/csv" \
-d @test.csv \
localhost:5000/predict
One common way of distributing this model API server for production deployment, is via Docker containers. And BentoML provides a convenient way to do that.
Note that docker is not available in Google Colab. You will need to download and run this notebook locally to try out this containerization with docker feature.
If you already have docker configured, simply run the follow command to product a docker container serving the IrisClassifier prediction service created above:
!bentoml containerize LeagueWinPrediction:latest
[2020-09-22 15:38:10,877] INFO - Getting latest version LeagueWinPrediction:20200922153614_15BE7D Found Bento: /Users/bozhaoyu/bentoml/repository/LeagueWinPrediction/20200922153614_15BE7D [2020-09-22 15:38:10,922] WARNING - Using BentoML installed in `editable` model, the local BentoML repository including all code changes will be packaged together with saved bundle created, under the './bundled_pip_dependencies' directory of the saved bundle. [2020-09-22 15:38:10,939] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015 Tag not specified, using tag parsed from BentoService: 'leaguewinprediction:20200922153614_15BE7D' Building Docker image leaguewinprediction:20200922153614_15BE7D from LeagueWinPrediction:latest -we in here processed docker file (None, None) root in create archive /Users/bozhaoyu/bentoml/repository/LeagueWinPrediction/20200922153614_15BE7D ['Dockerfile', 'LeagueWinPrediction', 'LeagueWinPrediction/__init__.py', 'LeagueWinPrediction/__pycache__', 'LeagueWinPrediction/__pycache__/lol_win_predictions.cpython-37.pyc', 'LeagueWinPrediction/artifacts', 'LeagueWinPrediction/artifacts/__init__.py', 'LeagueWinPrediction/artifacts/model.model', 'LeagueWinPrediction/bentoml.yml', 'LeagueWinPrediction/lol_win_predictions.py', 'MANIFEST.in', 'README.md', 'bentoml-init.sh', 'bentoml.yml', 'bundled_pip_dependencies', 'bundled_pip_dependencies/BentoML-0.9.0rc0+3.gcebf2015.tar.gz', 'docker-entrypoint.sh', 'environment.yml', 'python_version', 'requirements.txt', 'setup.py'] about to build about to upgrade params check each param and update if use config proxy if buildargs if shmsize if labels if cache from if target if network_mode if squash if extra hosts is not None if platform is not None if isolcation is not None if context is not None setting auth {'Content-Type': 'application/tar'} \docker build <tempfile._TemporaryFileWrapper object at 0x7ff1e6d75dd8> {'t': 'leaguewinprediction:20200922153614_15BE7D', 'remote': None, 'q': False, 'nocache': False, 'rm': False, 'forcerm': False, 'pull': False, 'dockerfile': (None, None)} |docker response <Response [200]> context closes print responses Step 1/15 : FROM bentoml/model-server:0.9.0.pre ---> a25066aa8b0e Step 2/15 : ARG EXTRA_PIP_INSTALL_ARGS= ---> Using cache ---> fc6e47d06522 Step 3/15 : ENV EXTRA_PIP_INSTALL_ARGS $EXTRA_PIP_INSTALL_ARGS ---> Using cache ---> db8172e98571 Step 4/15 : COPY environment.yml requirements.txt setup.sh* bentoml-init.sh python_version* /bento/ \ ---> 0d7364cd570c Step 5/15 : WORKDIR /bento ---> Running in f8b49e247b4b - ---> c7e443ac083a Step 6/15 : RUN chmod +x /bento/bentoml-init.sh / ---> Running in 7a86e0af06b7 \ ---> a555c7d51ca7 Step 7/15 : RUN if [ -f /bento/bentoml-init.sh ]; then bash -c /bento/bentoml-init.sh; fi ---> Running in ccd57d484032 |+++ dirname /bento/bentoml-init.sh ++ cd /bento ++ pwd -P + SAVED_BUNDLE_PATH=/bento + cd /bento + '[' -f ./setup.sh ']' + '[' -f ./python_version ']' ++ cat ./python_version + PY_VERSION_SAVED=3.7.3 + DESIRED_PY_VERSION=3.7 ++ python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' -Python Version in docker base image 3.7 matches requirement python=3.7. Skipping. + CURRENT_PY_VERSION=3.7 + [[ 3.7 == \3\.\7 ]] + echo 'Python Version in docker base image 3.7 matches requirement python=3.7. Skipping.' + command -v conda Updating conda base environment with environment.yml + echo 'Updating conda base environment with environment.yml' + conda env update -n base -f ./environment.yml |Collecting package metadata (repodata.json): ...working... -done Solving environment: ...working... \done - Downloading and Extracting Packages openssl-1.1.1h | 2.1 MB | | 0% openssl-1.1.1h | 2.1 MB | | 1% openssl-1.1.1h | 2.1 MB | ####2 | 43% openssl-1.1.1h | 2.1 MB | ########3 | 84% openssl-1.1.1h | 2.1 MB | ########## | 100% certifi-2020.6.20 | 151 KB | | 0% certifi-2020.6.20 | 151 KB | ########## | 100% python-3.7.9 | 45.3 MB | | 0% python-3.7.9 | 45.3 MB | | 0% python-3.7.9 | 45.3 MB | 1 | 2% python-3.7.9 | 45.3 MB | 3 | 3% python-3.7.9 | 45.3 MB | 6 | 6% python-3.7.9 | 45.3 MB | # | 11% python-3.7.9 | 45.3 MB | #5 | 15% python-3.7.9 | 45.3 MB | #9 | 19% python-3.7.9 | 45.3 MB | ##2 | 23% python-3.7.9 | 45.3 MB | ##6 | 26% python-3.7.9 | 45.3 MB | ### | 30% python-3.7.9 | 45.3 MB | ###5 | 35% python-3.7.9 | 45.3 MB | #### | 40% python-3.7.9 | 45.3 MB | ####5 | 45% python-3.7.9 | 45.3 MB | ##### | 50% python-3.7.9 | 45.3 MB | #####5 | 55% python-3.7.9 | 45.3 MB | ###### | 61% python-3.7.9 | 45.3 MB | ######6 | 66% python-3.7.9 | 45.3 MB | #######1 | 71% python-3.7.9 | 45.3 MB | #######5 | 76% python-3.7.9 | 45.3 MB | ########1 | 81% python-3.7.9 | 45.3 MB | ########6 | 86% python-3.7.9 | 45.3 MB | ######### | 91% python-3.7.9 | 45.3 MB | #########5 | 95% python-3.7.9 | 45.3 MB | #########9 | 100% python-3.7.9 | 45.3 MB | ########## | 100% python_abi-3.7 | 4 KB | | 0% python_abi-3.7 | 4 KB | ########## | 100% readline-8.0 | 281 KB | | 0% readline-8.0 | 281 KB | ######8 | 68% readline-8.0 | 281 KB | ########## | 100% pip-20.2.3 | 1.1 MB | | 0% pip-20.2.3 | 1.1 MB | ##6 | 26% pip-20.2.3 | 1.1 MB | ########## | 100% pip-20.2.3 | 1.1 MB | ########## | 100% ca-certificates-2020 | 145 KB | | 0% ca-certificates-2020 | 145 KB | ########## | 100% Preparing transaction: ...working... -done Verifying transaction: ...working... \done Executing transaction: ...working... -done \# # To activate this environment, use # # $ conda activate base # # To deactivate an active environment, use # # $ conda deactivate |+ pip install -r ./requirements.txt --no-cache-dir -Requirement already satisfied: bentoml==0.9.0.pre in /opt/conda/lib/python3.7/site-packages (from -r ./requirements.txt (line 1)) (0.9.0rc0) -Collecting xgboost==1.2.0 / Downloading xgboost-1.2.0-py3-none-manylinux2010_x86_64.whl (148.9 MB) |Collecting pandas==0.24.2 Downloading pandas-0.24.2-cp37-cp37m-manylinux1_x86_64.whl (10.1 MB) -Requirement already satisfied: certifi in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2020.6.20) Requirement already satisfied: flask in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.1.2) Requirement already satisfied: tabulate in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.8.7) Requirement already satisfied: py-zipkin in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.20.0) /Requirement already satisfied: multidict in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (4.7.6) Requirement already satisfied: cerberus in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.3.2) Requirement already satisfied: protobuf>=3.6.0 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.13.0) Requirement already satisfied: click>=7.0 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (7.1.2) Requirement already satisfied: alembic in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.4.3) Requirement already satisfied: ruamel.yaml>=0.15.0 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.15.87) Requirement already satisfied: humanfriendly in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (8.2) Requirement already satisfied: python-dateutil<3.0.0,>=2.7.3 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.8.1) Requirement already satisfied: requests in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.24.0) Requirement already satisfied: boto3 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.15.2) Requirement already satisfied: prometheus-client in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.8.0) Requirement already satisfied: sqlalchemy>=1.3.0 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.3.19) Requirement already satisfied: python-json-logger in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.1.11) Requirement already satisfied: gunicorn in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (20.0.4) Requirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.19.2) |Requirement already satisfied: grpcio<=1.27.2 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.27.2) Requirement already satisfied: docker in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (4.3.1) Requirement already satisfied: packaging in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (20.4) Requirement already satisfied: psutil in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (5.7.2) Requirement already satisfied: sqlalchemy-utils<0.36.8 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.36.7) \Requirement already satisfied: configparser in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (5.0.0) Requirement already satisfied: aiohttp in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.6.2) |Collecting scipy Downloading scipy-1.5.2-cp37-cp37m-manylinux1_x86_64.whl (25.9 MB) /Collecting pytz>=2011k Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB) |Requirement already satisfied: itsdangerous>=0.24 in /opt/conda/lib/python3.7/site-packages (from flask->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.1.0) Requirement already satisfied: Werkzeug>=0.15 in /opt/conda/lib/python3.7/site-packages (from flask->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.0.1) Requirement already satisfied: Jinja2>=2.10.1 in /opt/conda/lib/python3.7/site-packages (from flask->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.11.2) Requirement already satisfied: thriftpy2>=0.4.0 in /opt/conda/lib/python3.7/site-packages (from py-zipkin->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.4.11) Requirement already satisfied: six in /opt/conda/lib/python3.7/site-packages (from py-zipkin->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.15.0) Requirement already satisfied: setuptools in /opt/conda/lib/python3.7/site-packages (from cerberus->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (49.6.0.post20200814) Requirement already satisfied: Mako in /opt/conda/lib/python3.7/site-packages (from alembic->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.1.3) Requirement already satisfied: python-editor>=0.3 in /opt/conda/lib/python3.7/site-packages (from alembic->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.0.4) Requirement already satisfied: chardet<4,>=3.0.2 in /opt/conda/lib/python3.7/site-packages (from requests->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.0.4) Requirement already satisfied: idna<3,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.10) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/lib/python3.7/site-packages (from requests->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.25.10) Requirement already satisfied: botocore<1.19.0,>=1.18.2 in /opt/conda/lib/python3.7/site-packages (from boto3->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.18.2) Requirement already satisfied: s3transfer<0.4.0,>=0.3.0 in /opt/conda/lib/python3.7/site-packages (from boto3->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.3.3) Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /opt/conda/lib/python3.7/site-packages (from boto3->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.10.0) Requirement already satisfied: websocket-client>=0.32.0 in /opt/conda/lib/python3.7/site-packages (from docker->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.57.0) \Requirement already satisfied: pyparsing>=2.0.2 in /opt/conda/lib/python3.7/site-packages (from packaging->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.4.7) Requirement already satisfied: yarl<2.0,>=1.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.5.1) Requirement already satisfied: async-timeout<4.0,>=3.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.0.1) Requirement already satisfied: attrs>=17.3.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (20.2.0) Requirement already satisfied: MarkupSafe>=0.23 in /opt/conda/lib/python3.7/site-packages (from Jinja2>=2.10.1->flask->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.1.1) Requirement already satisfied: ply<4.0,>=3.4 in /opt/conda/lib/python3.7/site-packages (from thriftpy2>=0.4.0->py-zipkin->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.11) Requirement already satisfied: typing-extensions>=3.7.4; python_version < "3.8" in /opt/conda/lib/python3.7/site-packages (from yarl<2.0,>=1.0->aiohttp->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.7.4.3) -Installing collected packages: scipy, xgboost, pytz, pandas /Successfully installed pandas-0.24.2 pytz-2020.1 scipy-1.5.2 xgboost-1.2.0 - ---> cf3711f3c835 Step 8/15 : COPY . /bento | ---> 3c517e745ea8 Step 9/15 : RUN if [ -d /bento/bundled_pip_dependencies ]; then pip install -U bundled_pip_dependencies/* ;fi \ ---> Running in 3a7dd6434563 |Processing ./bundled_pip_dependencies/BentoML-0.9.0rc0+3.gcebf2015.tar.gz | Installing build dependencies: started | Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started \ Getting requirements to build wheel: finished with status 'done' Preparing wheel metadata: started / Preparing wheel metadata: finished with status 'done' \Requirement already satisfied, skipping upgrade: prometheus-client in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.8.0) Requirement already satisfied, skipping upgrade: aiohttp in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (3.6.2) Requirement already satisfied, skipping upgrade: docker in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (4.3.1) -Requirement already satisfied, skipping upgrade: py-zipkin in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.20.0) Requirement already satisfied, skipping upgrade: packaging in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (20.4) Requirement already satisfied, skipping upgrade: boto3 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.15.2) Requirement already satisfied, skipping upgrade: flask in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.1.2) Requirement already satisfied, skipping upgrade: requests in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (2.24.0) Requirement already satisfied, skipping upgrade: numpy in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.19.2) Requirement already satisfied, skipping upgrade: certifi in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (2020.6.20) Requirement already satisfied, skipping upgrade: ruamel.yaml>=0.15.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.15.87) Requirement already satisfied, skipping upgrade: python-json-logger in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.1.11) Requirement already satisfied, skipping upgrade: multidict in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (4.7.6) Requirement already satisfied, skipping upgrade: sqlalchemy>=1.3.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.3.19) Requirement already satisfied, skipping upgrade: click>=7.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (7.1.2) Requirement already satisfied, skipping upgrade: python-dateutil<3.0.0,>=2.7.3 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (2.8.1) Requirement already satisfied, skipping upgrade: humanfriendly in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (8.2) Requirement already satisfied, skipping upgrade: protobuf>=3.6.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (3.13.0) Requirement already satisfied, skipping upgrade: alembic in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.4.3) Requirement already satisfied, skipping upgrade: tabulate in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.8.7) Requirement already satisfied, skipping upgrade: cerberus in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.3.2) Requirement already satisfied, skipping upgrade: grpcio<=1.27.2 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.27.2) Requirement already satisfied, skipping upgrade: sqlalchemy-utils<0.36.8 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.36.7) /Requirement already satisfied, skipping upgrade: gunicorn in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (20.0.4) Requirement already satisfied, skipping upgrade: psutil in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (5.7.2) Requirement already satisfied, skipping upgrade: configparser in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (5.0.0) |Requirement already satisfied, skipping upgrade: yarl<2.0,>=1.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (1.5.1) Requirement already satisfied, skipping upgrade: async-timeout<4.0,>=3.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (3.0.1) Requirement already satisfied, skipping upgrade: chardet<4.0,>=2.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (3.0.4) Requirement already satisfied, skipping upgrade: attrs>=17.3.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (20.2.0) Requirement already satisfied, skipping upgrade: websocket-client>=0.32.0 in /opt/conda/lib/python3.7/site-packages (from docker->BentoML==0.9.0rc0+3.gcebf2015) (0.57.0) Requirement already satisfied, skipping upgrade: six>=1.4.0 in /opt/conda/lib/python3.7/site-packages (from docker->BentoML==0.9.0rc0+3.gcebf2015) (1.15.0) Requirement already satisfied, skipping upgrade: thriftpy2>=0.4.0 in /opt/conda/lib/python3.7/site-packages (from py-zipkin->BentoML==0.9.0rc0+3.gcebf2015) (0.4.11) Requirement already satisfied, skipping upgrade: pyparsing>=2.0.2 in /opt/conda/lib/python3.7/site-packages (from packaging->BentoML==0.9.0rc0+3.gcebf2015) (2.4.7) Requirement already satisfied, skipping upgrade: s3transfer<0.4.0,>=0.3.0 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.9.0rc0+3.gcebf2015) (0.3.3) Requirement already satisfied, skipping upgrade: jmespath<1.0.0,>=0.7.1 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.9.0rc0+3.gcebf2015) (0.10.0) Requirement already satisfied, skipping upgrade: botocore<1.19.0,>=1.18.2 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.9.0rc0+3.gcebf2015) (1.18.2) Requirement already satisfied, skipping upgrade: itsdangerous>=0.24 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.9.0rc0+3.gcebf2015) (1.1.0) Requirement already satisfied, skipping upgrade: Werkzeug>=0.15 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.9.0rc0+3.gcebf2015) (1.0.1) Requirement already satisfied, skipping upgrade: Jinja2>=2.10.1 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.9.0rc0+3.gcebf2015) (2.11.2) Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/lib/python3.7/site-packages (from requests->BentoML==0.9.0rc0+3.gcebf2015) (1.25.10) \Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests->BentoML==0.9.0rc0+3.gcebf2015) (2.10) Requirement already satisfied, skipping upgrade: setuptools in /opt/conda/lib/python3.7/site-packages (from protobuf>=3.6.0->BentoML==0.9.0rc0+3.gcebf2015) (49.6.0.post20200814) Requirement already satisfied, skipping upgrade: python-editor>=0.3 in /opt/conda/lib/python3.7/site-packages (from alembic->BentoML==0.9.0rc0+3.gcebf2015) (1.0.4) Requirement already satisfied, skipping upgrade: Mako in /opt/conda/lib/python3.7/site-packages (from alembic->BentoML==0.9.0rc0+3.gcebf2015) (1.1.3) Requirement already satisfied, skipping upgrade: typing-extensions>=3.7.4; python_version < "3.8" in /opt/conda/lib/python3.7/site-packages (from yarl<2.0,>=1.0->aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (3.7.4.3) Requirement already satisfied, skipping upgrade: ply<4.0,>=3.4 in /opt/conda/lib/python3.7/site-packages (from thriftpy2>=0.4.0->py-zipkin->BentoML==0.9.0rc0+3.gcebf2015) (3.11) Requirement already satisfied, skipping upgrade: MarkupSafe>=0.23 in /opt/conda/lib/python3.7/site-packages (from Jinja2>=2.10.1->flask->BentoML==0.9.0rc0+3.gcebf2015) (1.1.1) Building wheels for collected packages: BentoML Building wheel for BentoML (PEP 517): started - Building wheel for BentoML (PEP 517): finished with status 'done' Created wheel for BentoML: filename=BentoML-0.9.0rc0+3.gcebf2015-py3-none-any.whl size=3064091 sha256=8e787b2d7d257f7106558876f09d73902ba33b332788f147eefffacab48ccf04 Stored in directory: /root/.cache/pip/wheels/a0/45/41/62152db705af4ff47e7a3d6abf6247986eef4aa1b94a58d3b9 Successfully built BentoML -Installing collected packages: BentoML Attempting uninstall: BentoML Found existing installation: BentoML 0.9.0rc0 | Uninstalling BentoML-0.9.0rc0: / Successfully uninstalled BentoML-0.9.0rc0 |Successfully installed BentoML-0.9.0rc0+3.gcebf2015 \ ---> e42b40e1aa88 Step 10/15 : ENV PORT 5000 - ---> Running in 5f759f6f786b / ---> 000eb066d01b Step 11/15 : EXPOSE $PORT ---> Running in e1f3cbec65d9 | ---> be9e430ba73f Step 12/15 : COPY docker-entrypoint.sh /usr/local/bin/ - ---> 286540998c4c Step 13/15 : RUN chmod +x /usr/local/bin/docker-entrypoint.sh ---> Running in 5af2837f2622 | ---> 80d32914bfce Step 14/15 : ENTRYPOINT [ "docker-entrypoint.sh" ] \ ---> Running in 22ccfd449e4c - ---> 83b5dbe3de6f Step 15/15 : CMD ["bentoml", "serve-gunicorn", "/bento"] ---> Running in 81b057cf8222 / ---> aba92d537770 Successfully built aba92d537770 Successfully tagged leaguewinprediction:20200922153614_15BE7D Finished building leaguewinprediction:20200922153614_15BE7D from LeagueWinPrediction:latest
!docker run --rm -p 5000:5000 leaguewinprediction:20200922153614_15BE7D
[2020-09-22 22:40:28,656] INFO - Starting BentoML API server in production mode.. [2020-09-22 22:40:29,076] INFO - get_gunicorn_num_of_workers: 3, calculated by cpu count [2020-09-22 22:40:29 +0000] [1] [INFO] Starting gunicorn 20.0.4 [2020-09-22 22:40:29 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1) [2020-09-22 22:40:29 +0000] [1] [INFO] Using worker: sync [2020-09-22 22:40:29 +0000] [12] [INFO] Booting worker with pid: 12 [2020-09-22 22:40:29 +0000] [13] [INFO] Booting worker with pid: 13 [2020-09-22 22:40:29 +0000] [14] [INFO] Booting worker with pid: 14 [2020-09-22 22:40:29,370] WARNING - Using BentoML not from official PyPI release. In order to find the same version of BentoML when deploying your BentoService, you must set the 'core/bentoml_deploy_version' config to a http/git location of your BentoML fork, e.g.: 'bentoml_deploy_version = git+https://github.com/{username}/bentoml.git@{branch}' [2020-09-22 22:40:29,370] WARNING - Using BentoML not from official PyPI release. In order to find the same version of BentoML when deploying your BentoService, you must set the 'core/bentoml_deploy_version' config to a http/git location of your BentoML fork, e.g.: 'bentoml_deploy_version = git+https://github.com/{username}/bentoml.git@{branch}' [2020-09-22 22:40:29,390] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015 [2020-09-22 22:40:29,390] WARNING - Saved BentoService Python version mismatch: loading BentoService bundle created with Python version 3.7.3, but current environment version is 3.7.9. [2020-09-22 22:40:29,391] WARNING - Using BentoML not from official PyPI release. In order to find the same version of BentoML when deploying your BentoService, you must set the 'core/bentoml_deploy_version' config to a http/git location of your BentoML fork, e.g.: 'bentoml_deploy_version = git+https://github.com/{username}/bentoml.git@{branch}' [2020-09-22 22:40:29,391] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015 [2020-09-22 22:40:29,393] WARNING - Saved BentoService Python version mismatch: loading BentoService bundle created with Python version 3.7.3, but current environment version is 3.7.9. [2020-09-22 22:40:29,414] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015 [2020-09-22 22:40:29,414] WARNING - Saved BentoService Python version mismatch: loading BentoService bundle created with Python version 3.7.3, but current environment version is 3.7.9. [2020-09-22 22:40:30,144] WARNING - pip package requirement xgboost already exist [2020-09-22 22:40:30,145] WARNING - pip package requirement xgboost already exist [2020-09-22 22:40:30,146] WARNING - pip package requirement xgboost already exist ^C [2020-09-22 22:40:38 +0000] [1] [INFO] Handling signal: int [2020-09-22 22:40:38 +0000] [14] [INFO] Worker exiting (pid: 14) [2020-09-22 22:40:38 +0000] [13] [INFO] Worker exiting (pid: 13) [2020-09-22 22:40:38 +0000] [12] [INFO] Worker exiting (pid: 12)
bentoml.load is the API for loading a BentoML packaged model in python:
from bentoml import load
svc = load(saved_path)
print(svc.predict(Xt[:3]))
[2020-09-22 15:40:44,389] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015 [2020-09-22 15:40:44,391] WARNING - Module `lol_win_predictions` already loaded, using existing imported module. [2020-09-22 15:40:44,396] WARNING - pip package requirement pandas already exist [2020-09-22 15:40:44,397] WARNING - pip package requirement xgboost already exist [0.35312122 0.06715239 0.04428952]
BentoML cli supports loading and running a packaged model from CLI. With the DataframeInput adapter, the CLI command supports reading input Dataframe data from CLI argument or local csv or json files:
Xt[:3].to_csv('test.csv')
!bentoml run LeagueWinPrediction:latest predict --input-file test.csv
If you are at a small team with limited engineering or DevOps resources, try out automated deployment with BentoML CLI, currently supporting AWS Lambda, AWS SageMaker, and Azure Functions:
If the cloud platform you are working with is not on the list above, try out these step-by-step guide on manually deploying BentoML packaged model to cloud platforms:
Lastly, if you have a DevOps or ML Engineering team who's operating a Kubernetes or OpenShift cluster, use the following guides as references for implementating your deployment strategy: