BentoML Example

Titanic Survival Prediction with XGBoost

This is a BentoML Demo Project demonstrating how to package and serve XGBoost model for production using BentoML.

BentoML is an open source platform for machine learning model serving and deployment.

Let's get started! Impression

In [2]:
%reload_ext autoreload
%autoreload 2
%matplotlib inline

import warnings
warnings.filterwarnings("ignore")
In [ ]:
!pip install bentoml
!pip install xgboost numpy pandas
In [3]:
import pandas as pd
import numpy as np
import xgboost as xgb
import bentoml

Prepare Dataset

download dataset from https://www.kaggle.com/c/titanic/data

In [4]:
!mkdir data
!curl https://raw.githubusercontent.com/agconti/kaggle-titanic/master/data/train.csv -o ./data/train.csv
!curl https://raw.githubusercontent.com/agconti/kaggle-titanic/master/data/test.csv -o ./data/test.csv
mkdir: data: File exists
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 60302  100 60302    0     0   154k      0 --:--:-- --:--:-- --:--:--  154k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 28210  100 28210    0     0   103k      0 --:--:-- --:--:-- --:--:--  103k
In [5]:
train = pd.read_csv("./data/train.csv")
test  = pd.read_csv("./data/test.csv")
X_y_train = xgb.DMatrix(data=train[['Pclass', 'Age', 'Fare', 'SibSp', 'Parch']], label= train['Survived'])
X_test    = xgb.DMatrix(data=test[['Pclass', 'Age', 'Fare', 'SibSp', 'Parch']])
In [6]:
train[['Pclass', 'Age', 'Fare', 'SibSp', 'Parch', 'Survived']].head()
Out[6]:
Pclass Age Fare SibSp Parch Survived
0 3 22.0 7.2500 1 0 0
1 1 38.0 71.2833 1 0 1
2 3 26.0 7.9250 0 0 1
3 1 35.0 53.1000 1 0 1
4 3 35.0 8.0500 0 0 0

Model Training

In [7]:
params = {
          'base_score': np.mean(train['Survived']),
          'eta':  0.1,
          'max_depth': 3,
          'gamma' :3,
          'objective'   :'reg:linear',
          'eval_metric' :'mae'
         }
model = xgb.train(params=params, 
                  dtrain=X_y_train, 
                  num_boost_round=3)
In [8]:
y_test =  model.predict(X_test)
test['pred'] = y_test
test[['Pclass', 'Age', 'Fare', 'SibSp', 'Parch','pred']].iloc[10:].head(2)
Out[8]:
Pclass Age Fare SibSp Parch pred
10 3 NaN 7.8958 0 0 0.341580
11 1 46.0 26.0000 0 0 0.413966

Create BentoService for model serving

In [13]:
%%writefile xgboost_titanic_bento_service.py

import xgboost as xgb

import bentoml
from bentoml.artifact import XgboostModelArtifact
from bentoml.handlers import DataframeHandler

@bentoml.artifacts([XgboostModelArtifact('model')])
@bentoml.env(pip_dependencies=['xgboost'])
class TitanicSurvivalPredictionXgBoost(bentoml.BentoService):
    
    @bentoml.api(DataframeHandler)
    def predict(self, df):
        data = xgb.DMatrix(data=df[['Pclass', 'Age', 'Fare', 'SibSp', 'Parch']])
        return self.artifacts.model.predict(data)
Overwriting xgboost_titanic_bento_service.py

Save BentoML service archive

In [14]:
# 1) import the custom BentoService defined above
from xgboost_titanic_bento_service import TitanicSurvivalPredictionXgBoost

# 2) `pack` it with required artifacts
bento_service = TitanicSurvivalPredictionXgBoost()
bento_service.pack('model', model)

# 3) save your BentoSerivce
saved_path = bento_service.save()
[2020-01-23 10:02:56,315] WARNING - BentoML local changes detected - Local BentoML repository including all code changes will be bundled together with the BentoService bundle. When used with docker, the base docker image will be default to same version as last PyPI release at version: 0.5.8. You can also force bentoml to use a specific version for deploying your BentoService bundle, by setting the config 'core/bentoml_deploy_version' to a pinned version or your custom BentoML on github, e.g.:'bentoml_deploy_version = git+https://github.com/{username}/[email protected]{branch}'
[2020-01-23 10:02:56,337] WARNING - BentoML local changes detected - Local BentoML repository including all code changes will be bundled together with the BentoService bundle. When used with docker, the base docker image will be default to same version as last PyPI release at version: 0.5.8. You can also force bentoml to use a specific version for deploying your BentoService bundle, by setting the config 'core/bentoml_deploy_version' to a pinned version or your custom BentoML on github, e.g.:'bentoml_deploy_version = git+https://github.com/{username}/[email protected]{branch}'
[2020-01-23 10:03:08,109] WARNING - BentoML local changes detected - Local BentoML repository including all code changes will be bundled together with the BentoService bundle. When used with docker, the base docker image will be default to same version as last PyPI release at version: 0.5.8. You can also force bentoml to use a specific version for deploying your BentoService bundle, by setting the config 'core/bentoml_deploy_version' to a pinned version or your custom BentoML on github, e.g.:'bentoml_deploy_version = git+https://github.com/{username}/[email protected]{branch}'
running sdist
running egg_info
writing BentoML.egg-info/PKG-INFO
writing dependency_links to BentoML.egg-info/dependency_links.txt
writing entry points to BentoML.egg-info/entry_points.txt
writing requirements to BentoML.egg-info/requires.txt
writing top-level names to BentoML.egg-info/top_level.txt
reading manifest file 'BentoML.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'examples'
no previously-included directories found matching 'tests'
no previously-included directories found matching 'docs'
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
writing manifest file 'BentoML.egg-info/SOURCES.txt'
running check
warning: check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too

creating BentoML-0.6.0
creating BentoML-0.6.0/BentoML.egg-info
creating BentoML-0.6.0/bentoml
creating BentoML-0.6.0/bentoml/artifact
creating BentoML-0.6.0/bentoml/bundler
creating BentoML-0.6.0/bentoml/cli
creating BentoML-0.6.0/bentoml/clipper
creating BentoML-0.6.0/bentoml/configuration
creating BentoML-0.6.0/bentoml/deployment
creating BentoML-0.6.0/bentoml/deployment/aws_lambda
creating BentoML-0.6.0/bentoml/deployment/sagemaker
creating BentoML-0.6.0/bentoml/handlers
creating BentoML-0.6.0/bentoml/migrations
creating BentoML-0.6.0/bentoml/migrations/versions
creating BentoML-0.6.0/bentoml/proto
creating BentoML-0.6.0/bentoml/repository
creating BentoML-0.6.0/bentoml/server
creating BentoML-0.6.0/bentoml/server/static
creating BentoML-0.6.0/bentoml/utils
creating BentoML-0.6.0/bentoml/utils/validator
creating BentoML-0.6.0/bentoml/yatai
creating BentoML-0.6.0/bentoml/yatai/client
copying files to BentoML-0.6.0...
copying LICENSE -> BentoML-0.6.0
copying MANIFEST.in -> BentoML-0.6.0
copying README.md -> BentoML-0.6.0
copying pyproject.toml -> BentoML-0.6.0
copying setup.cfg -> BentoML-0.6.0
copying setup.py -> BentoML-0.6.0
copying versioneer.py -> BentoML-0.6.0
copying BentoML.egg-info/PKG-INFO -> BentoML-0.6.0/BentoML.egg-info
copying BentoML.egg-info/SOURCES.txt -> BentoML-0.6.0/BentoML.egg-info
copying BentoML.egg-info/dependency_links.txt -> BentoML-0.6.0/BentoML.egg-info
copying BentoML.egg-info/entry_points.txt -> BentoML-0.6.0/BentoML.egg-info
copying BentoML.egg-info/requires.txt -> BentoML-0.6.0/BentoML.egg-info
copying BentoML.egg-info/top_level.txt -> BentoML-0.6.0/BentoML.egg-info
copying bentoml/__init__.py -> BentoML-0.6.0/bentoml
copying bentoml/_version.py -> BentoML-0.6.0/bentoml
copying bentoml/alembic.ini -> BentoML-0.6.0/bentoml
copying bentoml/db.py -> BentoML-0.6.0/bentoml
copying bentoml/exceptions.py -> BentoML-0.6.0/bentoml
copying bentoml/service.py -> BentoML-0.6.0/bentoml
copying bentoml/service_env.py -> BentoML-0.6.0/bentoml
copying bentoml/artifact/__init__.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/fastai_model_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/h2o_model_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/keras_model_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/lightgbm_model_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/pickle_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/pytorch_model_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/sklearn_model_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/text_file_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/tf_savedmodel_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/artifact/xgboost_model_artifact.py -> BentoML-0.6.0/bentoml/artifact
copying bentoml/bundler/__init__.py -> BentoML-0.6.0/bentoml/bundler
copying bentoml/bundler/bundler.py -> BentoML-0.6.0/bentoml/bundler
copying bentoml/bundler/config.py -> BentoML-0.6.0/bentoml/bundler
copying bentoml/bundler/loader.py -> BentoML-0.6.0/bentoml/bundler
copying bentoml/bundler/py_module_utils.py -> BentoML-0.6.0/bentoml/bundler
copying bentoml/bundler/templates.py -> BentoML-0.6.0/bentoml/bundler
copying bentoml/bundler/utils.py -> BentoML-0.6.0/bentoml/bundler
copying bentoml/cli/__init__.py -> BentoML-0.6.0/bentoml/cli
copying bentoml/cli/aws_lambda.py -> BentoML-0.6.0/bentoml/cli
copying bentoml/cli/aws_sagemaker.py -> BentoML-0.6.0/bentoml/cli
copying bentoml/cli/bento.py -> BentoML-0.6.0/bentoml/cli
copying bentoml/cli/click_utils.py -> BentoML-0.6.0/bentoml/cli
copying bentoml/cli/config.py -> BentoML-0.6.0/bentoml/cli
copying bentoml/cli/deployment.py -> BentoML-0.6.0/bentoml/cli
copying bentoml/cli/utils.py -> BentoML-0.6.0/bentoml/cli
copying bentoml/clipper/__init__.py -> BentoML-0.6.0/bentoml/clipper
copying bentoml/configuration/__init__.py -> BentoML-0.6.0/bentoml/configuration
copying bentoml/configuration/configparser.py -> BentoML-0.6.0/bentoml/configuration
copying bentoml/configuration/default_bentoml.cfg -> BentoML-0.6.0/bentoml/configuration
copying bentoml/deployment/__init__.py -> BentoML-0.6.0/bentoml/deployment
copying bentoml/deployment/operator.py -> BentoML-0.6.0/bentoml/deployment
copying bentoml/deployment/store.py -> BentoML-0.6.0/bentoml/deployment
copying bentoml/deployment/utils.py -> BentoML-0.6.0/bentoml/deployment
copying bentoml/deployment/aws_lambda/__init__.py -> BentoML-0.6.0/bentoml/deployment/aws_lambda
copying bentoml/deployment/aws_lambda/download_extra_resources.py -> BentoML-0.6.0/bentoml/deployment/aws_lambda
copying bentoml/deployment/aws_lambda/lambda_app.py -> BentoML-0.6.0/bentoml/deployment/aws_lambda
copying bentoml/deployment/aws_lambda/utils.py -> BentoML-0.6.0/bentoml/deployment/aws_lambda
copying bentoml/deployment/sagemaker/__init__.py -> BentoML-0.6.0/bentoml/deployment/sagemaker
copying bentoml/deployment/sagemaker/sagemaker_nginx.conf -> BentoML-0.6.0/bentoml/deployment/sagemaker
copying bentoml/deployment/sagemaker/sagemaker_serve.py -> BentoML-0.6.0/bentoml/deployment/sagemaker
copying bentoml/deployment/sagemaker/sagemaker_wsgi.py -> BentoML-0.6.0/bentoml/deployment/sagemaker
copying bentoml/handlers/__init__.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/base_handlers.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/clipper_handler.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/dataframe_handler.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/fastai_image_handler.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/image_handler.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/json_handler.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/pytorch_tensor_handler.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/tensorflow_tensor_handler.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/handlers/utils.py -> BentoML-0.6.0/bentoml/handlers
copying bentoml/migrations/README -> BentoML-0.6.0/bentoml/migrations
copying bentoml/migrations/env.py -> BentoML-0.6.0/bentoml/migrations
copying bentoml/migrations/script.py.mako -> BentoML-0.6.0/bentoml/migrations
copying bentoml/migrations/versions/a6b00ae45279_add_last_updated_at_for_deployments.py -> BentoML-0.6.0/bentoml/migrations/versions
copying bentoml/proto/__init__.py -> BentoML-0.6.0/bentoml/proto
copying bentoml/proto/deployment_pb2.py -> BentoML-0.6.0/bentoml/proto
copying bentoml/proto/repository_pb2.py -> BentoML-0.6.0/bentoml/proto
copying bentoml/proto/status_pb2.py -> BentoML-0.6.0/bentoml/proto
copying bentoml/proto/yatai_service_pb2.py -> BentoML-0.6.0/bentoml/proto
copying bentoml/proto/yatai_service_pb2_grpc.py -> BentoML-0.6.0/bentoml/proto
copying bentoml/repository/__init__.py -> BentoML-0.6.0/bentoml/repository
copying bentoml/repository/metadata_store.py -> BentoML-0.6.0/bentoml/repository
copying bentoml/server/__init__.py -> BentoML-0.6.0/bentoml/server
copying bentoml/server/bento_api_server.py -> BentoML-0.6.0/bentoml/server
copying bentoml/server/bento_sagemaker_server.py -> BentoML-0.6.0/bentoml/server
copying bentoml/server/gunicorn_config.py -> BentoML-0.6.0/bentoml/server
copying bentoml/server/gunicorn_server.py -> BentoML-0.6.0/bentoml/server
copying bentoml/server/middlewares.py -> BentoML-0.6.0/bentoml/server
copying bentoml/server/utils.py -> BentoML-0.6.0/bentoml/server
copying bentoml/server/static/swagger-ui-bundle.js -> BentoML-0.6.0/bentoml/server/static
copying bentoml/server/static/swagger-ui.css -> BentoML-0.6.0/bentoml/server/static
copying bentoml/utils/__init__.py -> BentoML-0.6.0/bentoml/utils
copying bentoml/utils/cloudpickle.py -> BentoML-0.6.0/bentoml/utils
copying bentoml/utils/hybirdmethod.py -> BentoML-0.6.0/bentoml/utils
copying bentoml/utils/log.py -> BentoML-0.6.0/bentoml/utils
copying bentoml/utils/s3.py -> BentoML-0.6.0/bentoml/utils
copying bentoml/utils/tempdir.py -> BentoML-0.6.0/bentoml/utils
copying bentoml/utils/usage_stats.py -> BentoML-0.6.0/bentoml/utils
copying bentoml/utils/validator/__init__.py -> BentoML-0.6.0/bentoml/utils/validator
copying bentoml/yatai/__init__.py -> BentoML-0.6.0/bentoml/yatai
copying bentoml/yatai/deployment_utils.py -> BentoML-0.6.0/bentoml/yatai
copying bentoml/yatai/status.py -> BentoML-0.6.0/bentoml/yatai
copying bentoml/yatai/yatai_service_impl.py -> BentoML-0.6.0/bentoml/yatai
copying bentoml/yatai/client/__init__.py -> BentoML-0.6.0/bentoml/yatai/client
copying bentoml/yatai/client/bento_repository_api.py -> BentoML-0.6.0/bentoml/yatai/client
copying bentoml/yatai/client/deployment_api.py -> BentoML-0.6.0/bentoml/yatai/client
Writing BentoML-0.6.0/setup.cfg
UPDATING BentoML-0.6.0/bentoml/_version.py
set BentoML-0.6.0/bentoml/_version.py to '0.6.0'
Creating tar archive
removing 'BentoML-0.6.0' (and everything under it)
[2020-01-23 10:03:09,336] INFO - BentoService bundle 'TitanicSurvivalPredictionXgBoost:20200123100256_F85423' created at: /private/var/folders/kn/xnc9k74x03567n1mx2tfqnpr0000gn/T/bentoml-temp-vojjnte3
[2020-01-23 10:03:09,337] WARNING - BentoML local changes detected - Local BentoML repository including all code changes will be bundled together with the BentoService bundle. When used with docker, the base docker image will be default to same version as last PyPI release at version: 0.5.8. You can also force bentoml to use a specific version for deploying your BentoService bundle, by setting the config 'core/bentoml_deploy_version' to a pinned version or your custom BentoML on github, e.g.:'bentoml_deploy_version = git+https://github.com/{username}/[email protected]{branch}'
[2020-01-23 10:03:09,348] WARNING - Saved BentoService bundle version mismatch: loading BentoServie bundle create with BentoML version 0.5.8,  but loading from BentoML version 0.5.8+23.g1dd72d3
[2020-01-23 10:03:09,409] INFO - BentoService bundle 'TitanicSurvivalPredictionXgBoost:20200123100256_F85423' created at: /Users/bozhaoyu/bentoml/repository/TitanicSurvivalPredictionXgBoost/20200123100256_F85423

Load saved BentoService for serving

In [15]:
import bentoml

bento_model = bentoml.load(saved_path)

result = bento_model.predict(test)
test['pred'] = result
test[['Pclass', 'Age', 'Fare', 'SibSp', 'Parch','pred']].iloc[10:].head(2)
[2020-01-23 10:03:17,744] WARNING - BentoML local changes detected - Local BentoML repository including all code changes will be bundled together with the BentoService bundle. When used with docker, the base docker image will be default to same version as last PyPI release at version: 0.5.8. You can also force bentoml to use a specific version for deploying your BentoService bundle, by setting the config 'core/bentoml_deploy_version' to a pinned version or your custom BentoML on github, e.g.:'bentoml_deploy_version = git+https://github.com/{username}/[email protected]{branch}'
[2020-01-23 10:03:17,756] WARNING - Saved BentoService bundle version mismatch: loading BentoServie bundle create with BentoML version 0.5.8,  but loading from BentoML version 0.5.8+23.g1dd72d3
[2020-01-23 10:03:17,758] WARNING - Module `xgboost_titanic_bento_service` already loaded, using existing imported module.
[2020-01-23 10:03:17,762] WARNING - BentoML local changes detected - Local BentoML repository including all code changes will be bundled together with the BentoService bundle. When used with docker, the base docker image will be default to same version as last PyPI release at version: 0.5.8. You can also force bentoml to use a specific version for deploying your BentoService bundle, by setting the config 'core/bentoml_deploy_version' to a pinned version or your custom BentoML on github, e.g.:'bentoml_deploy_version = git+https://github.com/{username}/[email protected]{branch}'
Out[15]:
Pclass Age Fare SibSp Parch pred
10 3 NaN 7.8958 0 0 0.341580
11 1 46.0 26.0000 0 0 0.413966

Work with BentoML CLI

bentoml get <BentoServiceName> is great for list all versions of the BentoService

In [16]:
!bentoml get TitanicSurvivalPredictionXgBoost
BENTO_SERVICE                                           CREATED_AT        APIS                       ARTIFACTS
TitanicSurvivalPredictionXgBoost:20200123100256_F85423  2020-01-23 18:03  predict::DataframeHandler  model::XgboostModelArtifact

bentoml get <BentoService name>:<BentoService version> to access detailed information

In [18]:
!bentoml get TitanicSurvivalPredictionXgBoost:20200123100256_F85423
{
  "name": "TitanicSurvivalPredictionXgBoost",
  "version": "20200123100256_F85423",
  "uri": {
    "type": "LOCAL",
    "uri": "/Users/bozhaoyu/bentoml/repository/TitanicSurvivalPredictionXgBoost/20200123100256_F85423"
  },
  "bentoServiceMetadata": {
    "name": "TitanicSurvivalPredictionXgBoost",
    "version": "20200123100256_F85423",
    "createdAt": "2020-01-23T18:03:08.110800Z",
    "env": {
      "condaEnv": "name: bentoml-TitanicSurvivalPredictionXgBoost\nchannels:\n- defaults\ndependencies:\n- python=3.7.3\n- pip\n",
      "pipDependencies": "bentoml==0.5.8\nxgboost",
      "pythonVersion": "3.7.3"
    },
    "artifacts": [
      {
        "name": "model",
        "artifactType": "XgboostModelArtifact"
      }
    ],
    "apis": [
      {
        "name": "predict",
        "handlerType": "DataframeHandler",
        "docs": "BentoService API"
      }
    ]
  }
}

Use CLI to make predicition is easy. It's a great way to validate prediction result quickly

In [20]:
!bentoml run TitanicSurvivalPredictionXgBoost:20200123100256_F85423 predict --input '[{"Pclass": 1, "Age": 30, "Fare": 200, "SibSp": 1, "Parch": 0}]' --input '[{"Pclass": 1, "Age": 30, "Fare": 200, "SibSp": 1, "Parch": 0}]'
[2020-01-23 10:07:46,230] WARNING - Saved BentoService bundle version mismatch: loading BentoServie bundle create with BentoML version 0.5.8,  but loading from BentoML version 0.6.0
[0.46972126]

Model Serving via REST API

In your termnial, run the following command to start the REST API server:

In [17]:
!bentoml serve {saved_path}
[2020-01-23 10:03:35,393] WARNING - Saved BentoService bundle version mismatch: loading BentoServie bundle create with BentoML version 0.5.8,  but loading from BentoML version 0.6.0
 * Serving Flask app "TitanicSurvivalPredictionXgBoost" (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)
^C

Copy following command to make a curl request to Rest API server

curl -i \
--header "Content-Type: application/json" \
--request POST \
--data '[{"Pclass": 1, "Age": 30, "Fare": 200, "SibSp": 1, "Parch": 0}]' \
localhost:5000/predict

Containerize REST API server with Docker

The BentoService SavedBundle is structured to work as a docker build context, that can be directed used to build a docker image for API server. Simply use it as the docker build context directory:

In [25]:
!cd {saved_path} && docker build -t xgboost-titanic .
Sending build context to Docker daemon  1.009MB
Step 1/12 : FROM continuumio/miniconda3:4.7.12
 ---> 406f2b43ea59
Step 2/12 : ENTRYPOINT [ "/bin/bash", "-c" ]
 ---> Running in 93c24cd29a40
Removing intermediate container 93c24cd29a40
 ---> 9396b863b5c4
Step 3/12 : EXPOSE 5000
 ---> Running in c7fd89ae56aa
Removing intermediate container c7fd89ae56aa
 ---> b30397557310
Step 4/12 : RUN set -x      && apt-get update      && apt-get install --no-install-recommends --no-install-suggests -y libpq-dev build-essential      && rm -rf /var/lib/apt/lists/*
 ---> Running in aadff73e4e57
+ apt-get update
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [174 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7908 kB]
Fetched 8318 kB in 2s (3422 kB/s)
Reading package lists...
+ apt-get install --no-install-recommends --no-install-suggests -y libpq-dev build-essential
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-8 dpkg-dev g++
  g++-8 gcc gcc-8 libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev
  libcc1-0 libdpkg-perl libgcc-8-dev libgomp1 libisl19 libitm1 liblsan0
  libmpc3 libmpfr6 libmpx2 libpq5 libquadmath0 libstdc++-8-dev libtsan0
  libubsan1 linux-libc-dev make
Suggested packages:
  binutils-doc cpp-doc gcc-8-locales debian-keyring g++-multilib
  g++-8-multilib gcc-8-doc libstdc++6-8-dbg gcc-multilib manpages-dev autoconf
  automake libtool flex bison gdb gcc-doc gcc-8-multilib libgcc1-dbg
  libgomp1-dbg libitm1-dbg libatomic1-dbg libasan5-dbg liblsan0-dbg
  libtsan0-dbg libubsan1-dbg libmpx2-dbg libquadmath0-dbg glibc-doc gnupg
  | gnupg2 bzr postgresql-doc-11 libstdc++-8-doc make-doc
Recommended packages:
  fakeroot gnupg | gnupg2 libalgorithm-merge-perl manpages manpages-dev
  libfile-fcntllock-perl liblocale-gettext-perl
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-8
  dpkg-dev g++ g++-8 gcc gcc-8 libasan5 libatomic1 libbinutils libc-dev-bin
  libc6-dev libcc1-0 libdpkg-perl libgcc-8-dev libgomp1 libisl19 libitm1
  liblsan0 libmpc3 libmpfr6 libmpx2 libpq-dev libpq5 libquadmath0
  libstdc++-8-dev libtsan0 libubsan1 linux-libc-dev make
0 upgraded, 34 newly installed, 0 to remove and 26 not upgraded.
Need to get 47.1 MB of archives.
After this operation, 182 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 binutils-common amd64 2.31.1-16 [2073 kB]
Get:2 http://security.debian.org/debian-security buster/updates/main amd64 linux-libc-dev amd64 4.19.67-2+deb10u2 [1234 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 libbinutils amd64 2.31.1-16 [478 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 binutils-x86-64-linux-gnu amd64 2.31.1-16 [1823 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 binutils amd64 2.31.1-16 [56.8 kB]
Get:6 http://deb.debian.org/debian buster/main amd64 libc-dev-bin amd64 2.28-10 [275 kB]
Get:7 http://deb.debian.org/debian buster/main amd64 libc6-dev amd64 2.28-10 [2691 kB]
Get:8 http://deb.debian.org/debian buster/main amd64 libisl19 amd64 0.20-2 [587 kB]
Get:9 http://deb.debian.org/debian buster/main amd64 libmpfr6 amd64 4.0.2-1 [775 kB]
Get:10 http://deb.debian.org/debian buster/main amd64 libmpc3 amd64 1.1.0-1 [41.3 kB]
Get:11 http://deb.debian.org/debian buster/main amd64 cpp-8 amd64 8.3.0-6 [8914 kB]
Get:12 http://deb.debian.org/debian buster/main amd64 cpp amd64 4:8.3.0-1 [19.4 kB]
Get:13 http://deb.debian.org/debian buster/main amd64 libcc1-0 amd64 8.3.0-6 [46.6 kB]
Get:14 http://deb.debian.org/debian buster/main amd64 libgomp1 amd64 8.3.0-6 [75.8 kB]
Get:15 http://deb.debian.org/debian buster/main amd64 libitm1 amd64 8.3.0-6 [27.7 kB]
Get:16 http://deb.debian.org/debian buster/main amd64 libatomic1 amd64 8.3.0-6 [9032 B]
Get:17 http://deb.debian.org/debian buster/main amd64 libasan5 amd64 8.3.0-6 [362 kB]
Get:18 http://deb.debian.org/debian buster/main amd64 liblsan0 amd64 8.3.0-6 [131 kB]
Get:19 http://deb.debian.org/debian buster/main amd64 libtsan0 amd64 8.3.0-6 [283 kB]
Get:20 http://deb.debian.org/debian buster/main amd64 libubsan1 amd64 8.3.0-6 [120 kB]
Get:21 http://deb.debian.org/debian buster/main amd64 libmpx2 amd64 8.3.0-6 [11.4 kB]
Get:22 http://deb.debian.org/debian buster/main amd64 libquadmath0 amd64 8.3.0-6 [133 kB]
Get:23 http://deb.debian.org/debian buster/main amd64 libgcc-8-dev amd64 8.3.0-6 [2298 kB]
Get:24 http://deb.debian.org/debian buster/main amd64 gcc-8 amd64 8.3.0-6 [9452 kB]
Get:25 http://deb.debian.org/debian buster/main amd64 gcc amd64 4:8.3.0-1 [5196 B]
Get:26 http://deb.debian.org/debian buster/main amd64 libstdc++-8-dev amd64 8.3.0-6 [1532 kB]
Get:27 http://deb.debian.org/debian buster/main amd64 g++-8 amd64 8.3.0-6 [9752 kB]
Get:28 http://deb.debian.org/debian buster/main amd64 g++ amd64 4:8.3.0-1 [1644 B]
Get:29 http://deb.debian.org/debian buster/main amd64 make amd64 4.2.1-1.2 [341 kB]
Get:30 http://deb.debian.org/debian buster/main amd64 libdpkg-perl all 1.19.7 [1414 kB]
Get:31 http://deb.debian.org/debian buster/main amd64 dpkg-dev all 1.19.7 [1773 kB]
Get:32 http://deb.debian.org/debian buster/main amd64 build-essential amd64 12.6 [7576 B]
Get:33 http://deb.debian.org/debian buster/main amd64 libpq5 amd64 11.5-1+deb10u1 [166 kB]
Get:34 http://deb.debian.org/debian buster/main amd64 libpq-dev amd64 11.5-1+deb10u1 [161 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 47.1 MB in 9s (5110 kB/s)
Selecting previously unselected package binutils-common:amd64.
(Reading database ... 12557 files and directories currently installed.)
Preparing to unpack .../00-binutils-common_2.31.1-16_amd64.deb ...
Unpacking binutils-common:amd64 (2.31.1-16) ...
Selecting previously unselected package libbinutils:amd64.
Preparing to unpack .../01-libbinutils_2.31.1-16_amd64.deb ...
Unpacking libbinutils:amd64 (2.31.1-16) ...
Selecting previously unselected package binutils-x86-64-linux-gnu.
Preparing to unpack .../02-binutils-x86-64-linux-gnu_2.31.1-16_amd64.deb ...
Unpacking binutils-x86-64-linux-gnu (2.31.1-16) ...
Selecting previously unselected package binutils.
Preparing to unpack .../03-binutils_2.31.1-16_amd64.deb ...
Unpacking binutils (2.31.1-16) ...
Selecting previously unselected package libc-dev-bin.
Preparing to unpack .../04-libc-dev-bin_2.28-10_amd64.deb ...
Unpacking libc-dev-bin (2.28-10) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../05-linux-libc-dev_4.19.67-2+deb10u2_amd64.deb ...
Unpacking linux-libc-dev:amd64 (4.19.67-2+deb10u2) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../06-libc6-dev_2.28-10_amd64.deb ...
Unpacking libc6-dev:amd64 (2.28-10) ...
Selecting previously unselected package libisl19:amd64.
Preparing to unpack .../07-libisl19_0.20-2_amd64.deb ...
Unpacking libisl19:amd64 (0.20-2) ...
Selecting previously unselected package libmpfr6:amd64.
Preparing to unpack .../08-libmpfr6_4.0.2-1_amd64.deb ...
Unpacking libmpfr6:amd64 (4.0.2-1) ...
Selecting previously unselected package libmpc3:amd64.
Preparing to unpack .../09-libmpc3_1.1.0-1_amd64.deb ...
Unpacking libmpc3:amd64 (1.1.0-1) ...
Selecting previously unselected package cpp-8.
Preparing to unpack .../10-cpp-8_8.3.0-6_amd64.deb ...
Unpacking cpp-8 (8.3.0-6) ...
Selecting previously unselected package cpp.
Preparing to unpack .../11-cpp_4%3a8.3.0-1_amd64.deb ...
Unpacking cpp (4:8.3.0-1) ...
Selecting previously unselected package libcc1-0:amd64.
Preparing to unpack .../12-libcc1-0_8.3.0-6_amd64.deb ...
Unpacking libcc1-0:amd64 (8.3.0-6) ...
Selecting previously unselected package libgomp1:amd64.
Preparing to unpack .../13-libgomp1_8.3.0-6_amd64.deb ...
Unpacking libgomp1:amd64 (8.3.0-6) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../14-libitm1_8.3.0-6_amd64.deb ...
Unpacking libitm1:amd64 (8.3.0-6) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../15-libatomic1_8.3.0-6_amd64.deb ...
Unpacking libatomic1:amd64 (8.3.0-6) ...
Selecting previously unselected package libasan5:amd64.
Preparing to unpack .../16-libasan5_8.3.0-6_amd64.deb ...
Unpacking libasan5:amd64 (8.3.0-6) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../17-liblsan0_8.3.0-6_amd64.deb ...
Unpacking liblsan0:amd64 (8.3.0-6) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../18-libtsan0_8.3.0-6_amd64.deb ...
Unpacking libtsan0:amd64 (8.3.0-6) ...
Selecting previously unselected package libubsan1:amd64.
Preparing to unpack .../19-libubsan1_8.3.0-6_amd64.deb ...
Unpacking libubsan1:amd64 (8.3.0-6) ...
Selecting previously unselected package libmpx2:amd64.
Preparing to unpack .../20-libmpx2_8.3.0-6_amd64.deb ...
Unpacking libmpx2:amd64 (8.3.0-6) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../21-libquadmath0_8.3.0-6_amd64.deb ...
Unpacking libquadmath0:amd64 (8.3.0-6) ...
Selecting previously unselected package libgcc-8-dev:amd64.
Preparing to unpack .../22-libgcc-8-dev_8.3.0-6_amd64.deb ...
Unpacking libgcc-8-dev:amd64 (8.3.0-6) ...
Selecting previously unselected package gcc-8.
Preparing to unpack .../23-gcc-8_8.3.0-6_amd64.deb ...
Unpacking gcc-8 (8.3.0-6) ...
Selecting previously unselected package gcc.
Preparing to unpack .../24-gcc_4%3a8.3.0-1_amd64.deb ...
Unpacking gcc (4:8.3.0-1) ...
Selecting previously unselected package libstdc++-8-dev:amd64.
Preparing to unpack .../25-libstdc++-8-dev_8.3.0-6_amd64.deb ...
Unpacking libstdc++-8-dev:amd64 (8.3.0-6) ...
Selecting previously unselected package g++-8.
Preparing to unpack .../26-g++-8_8.3.0-6_amd64.deb ...
Unpacking g++-8 (8.3.0-6) ...
Selecting previously unselected package g++.
Preparing to unpack .../27-g++_4%3a8.3.0-1_amd64.deb ...
Unpacking g++ (4:8.3.0-1) ...
Selecting previously unselected package make.
Preparing to unpack .../28-make_4.2.1-1.2_amd64.deb ...
Unpacking make (4.2.1-1.2) ...
Selecting previously unselected package libdpkg-perl.
Preparing to unpack .../29-libdpkg-perl_1.19.7_all.deb ...
Unpacking libdpkg-perl (1.19.7) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../30-dpkg-dev_1.19.7_all.deb ...
Unpacking dpkg-dev (1.19.7) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../31-build-essential_12.6_amd64.deb ...
Unpacking build-essential (12.6) ...
Selecting previously unselected package libpq5:amd64.
Preparing to unpack .../32-libpq5_11.5-1+deb10u1_amd64.deb ...
Unpacking libpq5:amd64 (11.5-1+deb10u1) ...
Selecting previously unselected package libpq-dev.
Preparing to unpack .../33-libpq-dev_11.5-1+deb10u1_amd64.deb ...
Unpacking libpq-dev (11.5-1+deb10u1) ...
Setting up binutils-common:amd64 (2.31.1-16) ...
Setting up libpq5:amd64 (11.5-1+deb10u1) ...
Setting up linux-libc-dev:amd64 (4.19.67-2+deb10u2) ...
Setting up libpq-dev (11.5-1+deb10u1) ...
Setting up libgomp1:amd64 (8.3.0-6) ...
Setting up libasan5:amd64 (8.3.0-6) ...
Setting up make (4.2.1-1.2) ...
Setting up libmpfr6:amd64 (4.0.2-1) ...
Setting up libquadmath0:amd64 (8.3.0-6) ...
Setting up libmpc3:amd64 (1.1.0-1) ...
Setting up libatomic1:amd64 (8.3.0-6) ...
Setting up libdpkg-perl (1.19.7) ...
Setting up libmpx2:amd64 (8.3.0-6) ...
Setting up libubsan1:amd64 (8.3.0-6) ...
Setting up libisl19:amd64 (0.20-2) ...
Setting up libbinutils:amd64 (2.31.1-16) ...
Setting up cpp-8 (8.3.0-6) ...
Setting up libc-dev-bin (2.28-10) ...
Setting up libcc1-0:amd64 (8.3.0-6) ...
Setting up liblsan0:amd64 (8.3.0-6) ...
Setting up libitm1:amd64 (8.3.0-6) ...
Setting up binutils-x86-64-linux-gnu (2.31.1-16) ...
Setting up libtsan0:amd64 (8.3.0-6) ...
Setting up binutils (2.31.1-16) ...
Setting up dpkg-dev (1.19.7) ...
Setting up libgcc-8-dev:amd64 (8.3.0-6) ...
Setting up cpp (4:8.3.0-1) ...
Setting up libc6-dev:amd64 (2.28-10) ...
Setting up libstdc++-8-dev:amd64 (8.3.0-6) ...
Setting up gcc-8 (8.3.0-6) ...
Setting up gcc (4:8.3.0-1) ...
Setting up g++-8 (8.3.0-6) ...
Setting up g++ (4:8.3.0-1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.6) ...
Processing triggers for libc-bin (2.28-10) ...
+ rm -rf /var/lib/apt/lists/auxfiles /var/lib/apt/lists/deb.debian.org_debian_dists_buster-updates_InRelease /var/lib/apt/lists/deb.debian.org_debian_dists_buster-updates_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/deb.debian.org_debian_dists_buster_InRelease /var/lib/apt/lists/deb.debian.org_debian_dists_buster_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/lock /var/lib/apt/lists/partial /var/lib/apt/lists/security.debian.org_debian-security_dists_buster_updates_InRelease /var/lib/apt/lists/security.debian.org_debian-security_dists_buster_updates_main_binary-amd64_Packages.lz4
Removing intermediate container aadff73e4e57
 ---> 1fa8a63ec27d
Step 5/12 : RUN conda install pip numpy scipy       && pip install gunicorn
 ---> Running in 4ece37d063ef
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /opt/conda

  added / updated specs:
    - numpy
    - pip
    - scipy


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    blas-1.0                   |              mkl           6 KB
    ca-certificates-2019.11.27 |                0         124 KB
    certifi-2019.11.28         |           py37_0         153 KB
    conda-4.8.1                |           py37_0         2.8 MB
    intel-openmp-2019.4        |              243         729 KB
    libgfortran-ng-7.3.0       |       hdf63c60_0        1006 KB
    mkl-2019.4                 |              243       131.2 MB
    mkl-service-2.3.0          |   py37he904b0f_0         218 KB
    mkl_fft-1.0.15             |   py37ha843d7b_0         154 KB
    mkl_random-1.1.0           |   py37hd6b4f25_0         321 KB
    numpy-1.18.1               |   py37h4f9e942_0           5 KB
    numpy-base-1.18.1          |   py37hde5b4d6_1         4.2 MB
    openssl-1.1.1d             |       h7b6447c_3         2.5 MB
    pip-19.3.1                 |           py37_0         1.6 MB
    scipy-1.3.2                |   py37h7c811a0_0        13.9 MB
    ------------------------------------------------------------
                                           Total:       158.9 MB

The following NEW packages will be INSTALLED:

  blas               pkgs/main/linux-64::blas-1.0-mkl
  intel-openmp       pkgs/main/linux-64::intel-openmp-2019.4-243
  libgfortran-ng     pkgs/main/linux-64::libgfortran-ng-7.3.0-hdf63c60_0
  mkl                pkgs/main/linux-64::mkl-2019.4-243
  mkl-service        pkgs/main/linux-64::mkl-service-2.3.0-py37he904b0f_0
  mkl_fft            pkgs/main/linux-64::mkl_fft-1.0.15-py37ha843d7b_0
  mkl_random         pkgs/main/linux-64::mkl_random-1.1.0-py37hd6b4f25_0
  numpy              pkgs/main/linux-64::numpy-1.18.1-py37h4f9e942_0
  numpy-base         pkgs/main/linux-64::numpy-base-1.18.1-py37hde5b4d6_1
  scipy              pkgs/main/linux-64::scipy-1.3.2-py37h7c811a0_0

The following packages will be UPDATED:

  ca-certificates                               2019.8.28-0 --> 2019.11.27-0
  certifi                                  2019.9.11-py37_0 --> 2019.11.28-py37_0
  conda                                       4.7.12-py37_0 --> 4.8.1-py37_0
  openssl                                 1.1.1d-h7b6447c_2 --> 1.1.1d-h7b6447c_3
  pip                                         19.2.3-py37_0 --> 19.3.1-py37_0


Proceed ([y]/n)? 

Downloading and Extracting Packages
openssl-1.1.1d       | 2.5 MB    | ########## | 100% 
blas-1.0             | 6 KB      | ########## | 100% 
pip-19.3.1           | 1.6 MB    | ########## | 100% 
libgfortran-ng-7.3.0 | 1006 KB   | ########## | 100% 
ca-certificates-2019 | 124 KB    | ########## | 100% 
numpy-1.18.1         | 5 KB      | ########## | 100% 
conda-4.8.1          | 2.8 MB    | ########## | 100% 
certifi-2019.11.28   | 153 KB    | ########## | 100% 
numpy-base-1.18.1    | 4.2 MB    | ########## | 100% 
intel-openmp-2019.4  | 729 KB    | ########## | 100% 
mkl-2019.4           | 131.2 MB  | ########## | 100% 
mkl_fft-1.0.15       | 154 KB    | ########## | 100% 
mkl_random-1.1.0     | 321 KB    | ########## | 100% 
mkl-service-2.3.0    | 218 KB    | ########## | 100% 
scipy-1.3.2          | 13.9 MB   | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Collecting gunicorn
  Downloading https://files.pythonhosted.org/packages/69/ca/926f7cd3a2014b16870086b2d0fdc84a9e49473c68a8dff8b57f7c156f43/gunicorn-20.0.4-py2.py3-none-any.whl (77kB)
Requirement already satisfied: setuptools>=3.0 in /opt/conda/lib/python3.7/site-packages (from gunicorn) (41.4.0)
Installing collected packages: gunicorn
Successfully installed gunicorn-20.0.4
Removing intermediate container 4ece37d063ef
 ---> af9be1b65cf4
Step 6/12 : COPY . /bento
 ---> 788ae6da74b6
Step 7/12 : WORKDIR /bento
 ---> Running in 0d27a02d4438
Removing intermediate container 0d27a02d4438
 ---> 311fd807f113
Step 8/12 : RUN if [ -f /bento/setup.sh ]; then /bin/bash -c /bento/setup.sh; fi
 ---> Running in 23eac9b47e48
Removing intermediate container 23eac9b47e48
 ---> 744200f10e88
Step 9/12 : RUN conda env update -n base -f /bento/environment.yml
 ---> Running in ea085887724b
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

Downloading and Extracting Packages
python-3.7.3         | 32.1 MB   | ########## | 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

Removing intermediate container ea085887724b
 ---> 74b053f833f6
Step 10/12 : RUN pip install -r /bento/requirements.txt
 ---> Running in bc03870130f9
Collecting bentoml==0.5.8
  Downloading https://files.pythonhosted.org/packages/a4/ad/707fb1cd011fe772b803b5c106fa4fbb5e12448fa4db2ac42d01db4859cf/BentoML-0.5.8-py3-none-any.whl (537kB)
Collecting xgboost
  Downloading https://files.pythonhosted.org/packages/c1/24/5fe7237b2eca13ee0cfb100bec8c23f4e69ce9df852a64b0493d49dae4e0/xgboost-0.90-py2.py3-none-manylinux1_x86_64.whl (142.8MB)
Collecting ruamel.yaml>=0.15.0
  Downloading https://files.pythonhosted.org/packages/99/a8/25242fc81d0c02460e93e8cc7ec4ae60c2382c00ba0a0e1becc22e76548d/ruamel.yaml-0.16.6-py2.py3-none-any.whl (123kB)
Collecting protobuf>=3.6.0
  Downloading https://files.pythonhosted.org/packages/4a/14/f5c294f1e36a031f165128c25feba93b3116f15a74398d0b2747ed75744f/protobuf-3.11.2-cp37-cp37m-manylinux1_x86_64.whl (1.3MB)
Collecting cerberus
  Downloading https://files.pythonhosted.org/packages/90/a7/71c6ed2d46a81065e68c007ac63378b96fa54c7bb614d653c68232f9c50c/Cerberus-1.3.2.tar.gz (52kB)
Requirement already satisfied: requests in /opt/conda/lib/python3.7/site-packages (from bentoml==0.5.8->-r /bento/requirements.txt (line 1)) (2.22.0)
Collecting python-dateutil<2.8.1,>=2.1
  Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
Collecting sqlalchemy>=1.3.0
  Downloading https://files.pythonhosted.org/packages/af/47/35edeb0f86c0b44934c05d961c893e223ef27e79e1f53b5e6f14820ff553/SQLAlchemy-1.3.13.tar.gz (6.0MB)
Collecting humanfriendly
  Downloading https://files.pythonhosted.org/packages/90/df/88bff450f333114680698dc4aac7506ff7cab164b794461906de31998665/humanfriendly-4.18-py2.py3-none-any.whl (73kB)
Collecting flask
  Downloading https://files.pythonhosted.org/packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl (94kB)
Collecting tabulate
  Downloading https://files.pythonhosted.org/packages/c4/41/523f6a05e6dc3329a5660f6a81254c6cd87e5cfb5b7482bae3391d86ec3a/tabulate-0.8.6.tar.gz (45kB)
Collecting docker
  Downloading https://files.pythonhosted.org/packages/cc/ca/699d4754a932787ef353a157ada74efd1ceb6d1fc0bfb7989ae1e7b33111/docker-4.1.0-py2.py3-none-any.whl (139kB)
Collecting grpcio
  Downloading https://files.pythonhosted.org/packages/bc/b3/0052e38c640d52b710e235b15821cc3c61d0065bf54e70a44550ef127349/grpcio-1.26.0-cp37-cp37m-manylinux2010_x86_64.whl (2.4MB)
Requirement already satisfied: gunicorn in /opt/conda/lib/python3.7/site-packages (from bentoml==0.5.8->-r /bento/requirements.txt (line 1)) (20.0.4)
Collecting packaging
  Downloading https://files.pythonhosted.org/packages/d8/5b/3098db49a61ccc8583ffead6aedc226f08ff56dc03106b6ec54451e27a30/packaging-20.0-py2.py3-none-any.whl
Collecting boto3
  Downloading https://files.pythonhosted.org/packages/ff/b5/3595b837d2aaf45b93adb8db44bb4ed07c04b3ce9ff6c399350314c779d2/boto3-1.11.8-py2.py3-none-any.whl (128kB)
Collecting alembic
  Downloading https://files.pythonhosted.org/packages/9d/c9/d4aa3be3511dfd6d86f8f483ce0d9f120258be4aceadc17601843593e2ec/alembic-1.3.3.tar.gz (1.1MB)
Collecting prometheus-client
  Downloading https://files.pythonhosted.org/packages/b3/23/41a5a24b502d35a4ad50a5bb7202a5e1d9a0364d0c12f56db3dbf7aca76d/prometheus_client-0.7.1.tar.gz
Collecting click>=7.0
  Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
Collecting pandas
  Downloading https://files.pythonhosted.org/packages/63/e0/a1b39cdcb2c391f087a1538bc8a6d62a82d0439693192aef541d7b123769/pandas-0.25.3-cp37-cp37m-manylinux1_x86_64.whl (10.4MB)
Requirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (from bentoml==0.5.8->-r /bento/requirements.txt (line 1)) (1.18.1)
Collecting configparser
  Downloading https://files.pythonhosted.org/packages/7a/2a/95ed0501cf5d8709490b1d3a3f9b5cf340da6c433f896bbe9ce08dbe6785/configparser-4.0.2-py2.py3-none-any.whl
Collecting python-json-logger
  Downloading https://files.pythonhosted.org/packages/80/9d/1c3393a6067716e04e6fcef95104c8426d262b4adaf18d7aa2470eab028d/python-json-logger-0.1.11.tar.gz
Requirement already satisfied: scipy in /opt/conda/lib/python3.7/site-packages (from xgboost->-r /bento/requirements.txt (line 2)) (1.3.2)
Collecting ruamel.yaml.clib>=0.1.2; platform_python_implementation == "CPython" and python_version < "3.8"
  Downloading https://files.pythonhosted.org/packages/40/80/da16b691d5e259dd9919a10628e541fca321cb4b078fbb88e1c7c22aa42d/ruamel.yaml.clib-0.2.0-cp37-cp37m-manylinux1_x86_64.whl (547kB)
Requirement already satisfied: six>=1.9 in /opt/conda/lib/python3.7/site-packages (from protobuf>=3.6.0->bentoml==0.5.8->-r /bento/requirements.txt (line 1)) (1.12.0)
Requirement already satisfied: setuptools in /opt/conda/lib/python3.7/site-packages (from protobuf>=3.6.0->bentoml==0.5.8->-r /bento/requirements.txt (line 1)) (41.4.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/conda/lib/python3.7/site-packages (from requests->bentoml==0.5.8->-r /bento/requirements.txt (line 1)) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.7/site-packages (from requests->bentoml==0.5.8->-r /bento/requirements.txt (line 1)) (2019.11.28)
Requirement already satisfied: idna<2.9,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests->bentoml==0.5.8->-r /bento/requirements.txt (line 1)) (2.8)
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.5.8->-r /bento/requirements.txt (line 1)) (1.24.2)
Collecting Jinja2>=2.10.1
  Downloading https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2-2.10.3-py2.py3-none-any.whl (125kB)
Collecting itsdangerous>=0.24
  Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting Werkzeug>=0.15
  Downloading https://files.pythonhosted.org/packages/ce/42/3aeda98f96e85fd26180534d36570e4d18108d62ae36f87694b476b83d6f/Werkzeug-0.16.0-py2.py3-none-any.whl (327kB)
Collecting websocket-client>=0.32.0
  Downloading https://files.pythonhosted.org/packages/4c/5f/f61b420143ed1c8dc69f9eaec5ff1ac36109d52c80de49d66e0c36c3dfdf/websocket_client-0.57.0-py2.py3-none-any.whl (200kB)
Collecting pyparsing>=2.0.2
  Downloading https://files.pythonhosted.org/packages/5d/bc/1e58593167fade7b544bfe9502a26dc860940a79ab306e651e7f13be68c2/pyparsing-2.4.6-py2.py3-none-any.whl (67kB)
Collecting botocore<1.15.0,>=1.14.8
  Downloading https://files.pythonhosted.org/packages/61/f3/f06005f90a09bbdd4bc6df76400f0ac279f7e1f556d635ab60fb1f916d1b/botocore-1.14.8-py2.py3-none-any.whl (5.9MB)
Collecting jmespath<1.0.0,>=0.7.1
  Downloading https://files.pythonhosted.org/packages/83/94/7179c3832a6d45b266ddb2aac329e101367fbdb11f425f13771d27f225bb/jmespath-0.9.4-py2.py3-none-any.whl
Collecting s3transfer<0.4.0,>=0.3.0
  Downloading https://files.pythonhosted.org/packages/c7/48/a8252b6b3cd31774eab312b19d58a6ac55f296240c206617dcd38cd93bf8/s3transfer-0.3.2-py2.py3-none-any.whl (69kB)
Collecting Mako
  Downloading https://files.pythonhosted.org/packages/28/03/329b21f00243fc2d3815399413845dbbfb0745cff38a29d3597e97f8be58/Mako-1.1.1.tar.gz (468kB)
Collecting python-editor>=0.3
  Downloading https://files.pythonhosted.org/packages/c6/d3/201fc3abe391bbae6606e6f1d598c15d367033332bd54352b12f35513717/python_editor-1.0.4-py3-none-any.whl
Collecting pytz>=2017.2
  Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
Collecting MarkupSafe>=0.23
  Downloading https://files.pythonhosted.org/packages/98/7b/ff284bd8c80654e471b769062a9b43cc5d03e7a615048d96f4619df8d420/MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl
Collecting docutils<0.16,>=0.10
  Downloading https://files.pythonhosted.org/packages/22/cd/a6aa959dca619918ccb55023b4cb151949c64d4d5d55b3f4ffd7eee0c6e8/docutils-0.15.2-py3-none-any.whl (547kB)
Building wheels for collected packages: cerberus, sqlalchemy, tabulate, alembic, prometheus-client, python-json-logger, Mako
  Building wheel for cerberus (setup.py): started
  Building wheel for cerberus (setup.py): finished with status 'done'
  Created wheel for cerberus: filename=Cerberus-1.3.2-cp37-none-any.whl size=54336 sha256=5973e516f156897a190902d7ee12ec0bc6690841df13252860c41e43948829a9
  Stored in directory: /root/.cache/pip/wheels/e9/38/1f/f2cc84182676f3ae7134b9b2d744f9c235b24d2ddc8f7fe465
  Building wheel for sqlalchemy (setup.py): started
  Building wheel for sqlalchemy (setup.py): finished with status 'done'
  Created wheel for sqlalchemy: filename=SQLAlchemy-1.3.13-cp37-cp37m-linux_x86_64.whl size=1223694 sha256=36cd2bfd1cfc483675c6f0fab7600e55e68948bd3adc70438ac9691207f8ca91
  Stored in directory: /root/.cache/pip/wheels/b3/35/98/4c9cb3fd63d21d5606b972dd70643769745adf60e622467b71
  Building wheel for tabulate (setup.py): started
  Building wheel for tabulate (setup.py): finished with status 'done'
  Created wheel for tabulate: filename=tabulate-0.8.6-cp37-none-any.whl size=23274 sha256=27ad315dffe1608cd32e548cebab77b37fb789c541cb5cc2d4071cd5088188e0
  Stored in directory: /root/.cache/pip/wheels/9c/9b/f4/eb243fdb89676ec00588e8c54bb54360724c06e7fafe95278e
  Building wheel for alembic (setup.py): started
  Building wheel for alembic (setup.py): finished with status 'done'
  Created wheel for alembic: filename=alembic-1.3.3-py2.py3-none-any.whl size=155684 sha256=9d92fe3f8627d153faa10667529b98c1536d8e3b8e74faebc189e080e5959c84
  Stored in directory: /root/.cache/pip/wheels/12/6a/49/94a4af65af2edbccf9f467c0f4b26f24d0e5b61be0d8a7e066
  Building wheel for prometheus-client (setup.py): started
  Building wheel for prometheus-client (setup.py): finished with status 'done'
  Created wheel for prometheus-client: filename=prometheus_client-0.7.1-cp37-none-any.whl size=41402 sha256=9618c114f56b7f5b1eb069c9af9af73a5e6c70b5f8917348d96339e4eab3db96
  Stored in directory: /root/.cache/pip/wheels/1c/54/34/fd47cd9b308826cc4292b54449c1899a30251ef3b506bc91ea
  Building wheel for python-json-logger (setup.py): started
  Building wheel for python-json-logger (setup.py): finished with status 'done'
  Created wheel for python-json-logger: filename=python_json_logger-0.1.11-py2.py3-none-any.whl size=5076 sha256=c94a8c80dbdc78459d784448c933454348eb63dbb224949438e1a3642dbece34
  Stored in directory: /root/.cache/pip/wheels/97/f7/a1/752e22bb30c1cfe38194ea0070a5c66e76ef4d06ad0c7dc401
  Building wheel for Mako (setup.py): started
  Building wheel for Mako (setup.py): finished with status 'done'
  Created wheel for Mako: filename=Mako-1.1.1-cp37-none-any.whl size=75411 sha256=0e54e9bd95339d3017dbd2db23ab6984445c128bd2f3c3f1dbf664dd1afbe099
  Stored in directory: /root/.cache/pip/wheels/ff/50/a9/0ddeed8679a1fb65bf4677cb9c92701828b2c1821e22ef72fd
Successfully built cerberus sqlalchemy tabulate alembic prometheus-client python-json-logger Mako
Installing collected packages: ruamel.yaml.clib, ruamel.yaml, protobuf, cerberus, python-dateutil, sqlalchemy, humanfriendly, click, MarkupSafe, Jinja2, itsdangerous, Werkzeug, flask, tabulate, websocket-client, docker, grpcio, pyparsing, packaging, docutils, jmespath, botocore, s3transfer, boto3, Mako, python-editor, alembic, prometheus-client, pytz, pandas, configparser, python-json-logger, bentoml, xgboost
Successfully installed Jinja2-2.10.3 Mako-1.1.1 MarkupSafe-1.1.1 Werkzeug-0.16.0 alembic-1.3.3 bentoml-0.5.8 boto3-1.11.8 botocore-1.14.8 cerberus-1.3.2 click-7.0 configparser-4.0.2 docker-4.1.0 docutils-0.15.2 flask-1.1.1 grpcio-1.26.0 humanfriendly-4.18 itsdangerous-1.1.0 jmespath-0.9.4 packaging-20.0 pandas-0.25.3 prometheus-client-0.7.1 protobuf-3.11.2 pyparsing-2.4.6 python-dateutil-2.8.0 python-editor-1.0.4 python-json-logger-0.1.11 pytz-2019.3 ruamel.yaml-0.16.6 ruamel.yaml.clib-0.2.0 s3transfer-0.3.2 sqlalchemy-1.3.13 tabulate-0.8.6 websocket-client-0.57.0 xgboost-0.90
Removing intermediate container bc03870130f9
 ---> 35b2dd3e11e2
Step 11/12 : RUN if [ -f /bento/bentoml_init.sh ]; then /bin/bash -c /bento/bentoml_init.sh; fi
 ---> Running in df680189a88c
Processing ./bundled_pip_dependencies/BentoML-0.6.0.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: sqlalchemy>=1.3.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (1.3.13)
Requirement already satisfied, skipping upgrade: ruamel.yaml>=0.15.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (0.16.6)
Requirement already satisfied, skipping upgrade: configparser in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (4.0.2)
Requirement already satisfied, skipping upgrade: prometheus-client in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (0.7.1)
Requirement already satisfied, skipping upgrade: packaging in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (20.0)
Requirement already satisfied, skipping upgrade: tabulate in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (0.8.6)
Requirement already satisfied, skipping upgrade: protobuf>=3.6.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (3.11.2)
Requirement already satisfied, skipping upgrade: flask in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (1.1.1)
Requirement already satisfied, skipping upgrade: python-json-logger in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (0.1.11)
Requirement already satisfied, skipping upgrade: gunicorn in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (20.0.4)
Requirement already satisfied, skipping upgrade: boto3 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (1.11.8)
Requirement already satisfied, skipping upgrade: click>=7.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (7.0)
Requirement already satisfied, skipping upgrade: requests in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (2.22.0)
Requirement already satisfied, skipping upgrade: grpcio in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (1.26.0)
Requirement already satisfied, skipping upgrade: docker in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (4.1.0)
Requirement already satisfied, skipping upgrade: humanfriendly in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (4.18)
Requirement already satisfied, skipping upgrade: pandas in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (0.25.3)
Requirement already satisfied, skipping upgrade: alembic in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (1.3.3)
Requirement already satisfied, skipping upgrade: python-dateutil<2.8.1,>=2.1 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (2.8.0)
Requirement already satisfied, skipping upgrade: cerberus in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (1.3.2)
Requirement already satisfied, skipping upgrade: numpy in /opt/conda/lib/python3.7/site-packages (from BentoML==0.6.0) (1.18.1)
Requirement already satisfied, skipping upgrade: ruamel.yaml.clib>=0.1.2; platform_python_implementation == "CPython" and python_version < "3.8" in /opt/conda/lib/python3.7/site-packages (from ruamel.yaml>=0.15.0->BentoML==0.6.0) (0.2.0)
Requirement already satisfied, skipping upgrade: six in /opt/conda/lib/python3.7/site-packages (from packaging->BentoML==0.6.0) (1.12.0)
Requirement already satisfied, skipping upgrade: pyparsing>=2.0.2 in /opt/conda/lib/python3.7/site-packages (from packaging->BentoML==0.6.0) (2.4.6)
Requirement already satisfied, skipping upgrade: setuptools in /opt/conda/lib/python3.7/site-packages (from protobuf>=3.6.0->BentoML==0.6.0) (41.4.0)
Requirement already satisfied, skipping upgrade: itsdangerous>=0.24 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.6.0) (1.1.0)
Requirement already satisfied, skipping upgrade: Jinja2>=2.10.1 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.6.0) (2.10.3)
Requirement already satisfied, skipping upgrade: Werkzeug>=0.15 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.6.0) (0.16.0)
Requirement already satisfied, skipping upgrade: jmespath<1.0.0,>=0.7.1 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.6.0) (0.9.4)
Requirement already satisfied, skipping upgrade: s3transfer<0.4.0,>=0.3.0 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.6.0) (0.3.2)
Requirement already satisfied, skipping upgrade: botocore<1.15.0,>=1.14.8 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.6.0) (1.14.8)
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests->BentoML==0.6.0) (2.8)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /opt/conda/lib/python3.7/site-packages (from requests->BentoML==0.6.0) (3.0.4)
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.6.0) (1.24.2)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /opt/conda/lib/python3.7/site-packages (from requests->BentoML==0.6.0) (2019.11.28)
Requirement already satisfied, skipping upgrade: websocket-client>=0.32.0 in /opt/conda/lib/python3.7/site-packages (from docker->BentoML==0.6.0) (0.57.0)
Requirement already satisfied, skipping upgrade: pytz>=2017.2 in /opt/conda/lib/python3.7/site-packages (from pandas->BentoML==0.6.0) (2019.3)
Requirement already satisfied, skipping upgrade: Mako in /opt/conda/lib/python3.7/site-packages (from alembic->BentoML==0.6.0) (1.1.1)
Requirement already satisfied, skipping upgrade: python-editor>=0.3 in /opt/conda/lib/python3.7/site-packages (from alembic->BentoML==0.6.0) (1.0.4)
Requirement already satisfied, skipping upgrade: MarkupSafe>=0.23 in /opt/conda/lib/python3.7/site-packages (from Jinja2>=2.10.1->flask->BentoML==0.6.0) (1.1.1)
Requirement already satisfied, skipping upgrade: docutils<0.16,>=0.10 in /opt/conda/lib/python3.7/site-packages (from botocore<1.15.0,>=1.14.8->boto3->BentoML==0.6.0) (0.15.2)
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.6.0-cp37-none-any.whl size=505613 sha256=845d77f46f305a6018cbf1dd8dcc7a118f91ca442919fe8d595d2cc4435e603d
  Stored in directory: /root/.cache/pip/wheels/18/42/e5/7aade3a0ee2b7f6405b1751a9d08ca5d884cc501f6c2d72784
Successfully built BentoML
Installing collected packages: BentoML
  Found existing installation: BentoML 0.5.8
    Uninstalling BentoML-0.5.8:
      Successfully uninstalled BentoML-0.5.8
Successfully installed BentoML-0.6.0
Removing intermediate container df680189a88c
 ---> 736f91717cbd
Step 12/12 : CMD ["bentoml serve-gunicorn /bento"]
 ---> Running in 5575114fc642
Removing intermediate container 5575114fc642
 ---> 0462a3003826
Successfully built 0462a3003826
Successfully tagged xgboost-titanic:latest

Next, you can docker push the image to your choice of registry for deployment, or run it locally for development and testing:

In [28]:
!docker run -p 5000:5000 xgboost-titanic
Traceback (most recent call last):
  File "/opt/conda/bin/bentoml", line 8, in <module>
    sys.exit(cli())
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/bentoml/cli/click_utils.py", line 94, in wrapper
    return func(*args, **kwargs)
TypeError: serve_gunicorn() got an unexpected keyword argument 'bundle_path'

Deploy BentoService as REST API server to the cloud

BentoML support deployment to multiply cloud provider services, such as AWS Lambda, AWS Sagemaker, Google Cloudrun and etc. You can find the full list and guide on the documentation site at https://docs.bentoml.org/en/latest/deployment/index.html

For fastai pet classification, we are going to deploy to AWS Lambda

In [21]:
!bentoml lambda deploy first-xgboost-titanic \
    -b TitanicSurvivalPredictionXgBoost:20200123100256_F85423
Deploying Lambda deployment \[2020-01-23 10:09:56,484] INFO - Building lambda project
-[2020-01-23 10:14:15,686] INFO - Packaging AWS Lambda project at /private/var/folders/kn/xnc9k74x03567n1mx2tfqnpr0000gn/T/bentoml-temp-cmmyid7z ...
|[2020-01-23 10:14:51,480] INFO - Deploying lambda project
\[2020-01-23 10:15:44,909] INFO - ApplyDeployment (first-xgboost-titanic, namespace dev) succeeded
Successfully created AWS Lambda deployment first-xgboost-titanic
{
  "namespace": "dev",
  "name": "first-xgboost-titanic",
  "spec": {
    "bentoName": "TitanicSurvivalPredictionXgBoost",
    "bentoVersion": "20200123100256_F85423",
    "operator": "AWS_LAMBDA",
    "awsLambdaOperatorConfig": {
      "region": "us-west-2",
      "memorySize": 1024,
      "timeout": 3
    }
  },
  "state": {
    "state": "RUNNING",
    "infoJson": {
      "endpoints": [
        "https://8hsc80mck8.execute-api.us-west-2.amazonaws.com/Prod/predict"
      ],
      "s3_bucket": "btml-dev-first-xgboost-titanic-18bf13"
    },
    "timestamp": "2020-01-23T18:15:45.219387Z"
  },
  "createdAt": "2020-01-23T18:09:51.245401Z",
  "lastUpdatedAt": "2020-01-23T18:09:51.245442Z"
}
In [22]:
!bentoml lambda get first-xgboost-titanic
{
  "namespace": "dev",
  "name": "first-xgboost-titanic",
  "spec": {
    "bentoName": "TitanicSurvivalPredictionXgBoost",
    "bentoVersion": "20200123100256_F85423",
    "operator": "AWS_LAMBDA",
    "awsLambdaOperatorConfig": {
      "region": "us-west-2",
      "memorySize": 1024,
      "timeout": 3
    }
  },
  "state": {
    "state": "RUNNING",
    "infoJson": {
      "endpoints": [
        "https://8hsc80mck8.execute-api.us-west-2.amazonaws.com/Prod/predict"
      ],
      "s3_bucket": "btml-dev-first-xgboost-titanic-18bf13"
    },
    "timestamp": "2020-01-23T18:20:36.476533Z"
  },
  "createdAt": "2020-01-23T18:09:51.245401Z",
  "lastUpdatedAt": "2020-01-23T18:09:51.245442Z"
}

To send request to your AWS Lambda deployment, grab the endpoint URL from the json output above:

In [23]:
!curl -i \
--header "Content-Type: application/json" \
--request POST \
--data '[{"Pclass": 1, "Age": 30, "Fare": 200, "SibSp": 1, "Parch": 0}]' \
https://8hsc80mck8.execute-api.us-west-2.amazonaws.com/Prod/predict











[0.469721257686615]

Use bentoml lambda delete to remove AWS Lambda deployment

In [24]:
!bentoml lambda delete first-xgboost-titanic
Successfully deleted AWS Lambda deployment "first-xgboost-titanic"
In [ ]: