BentoML classification model train, test and build
- python
- pip
- pipenv (optional)
- docker
pip install -r ./requirements.txt
or with pipenv
pipenv install
python ./train.py
or with pipenv
pipenv run python ./train.py
bentoml serve service.py:svc
or with pipenv
pipenv run bentoml serve service.py:svc
Test the /predict
endpoint with expected input:
$ curl -X POST -H "content-type: application/json" --data '{"sepal_len": 7.2, "sepal_width": 3.2, "petal_len": 5.2, "petal_width": 2.2}' http://127.0.0.1:3000/classify
Test sending request with optional field:
$ curl -X POST -H "content-type: application/json" --data '{"sepal_len": 7.2, "sepal_width": 3.2, "petal_len": 5.2, "petal_width": 2.2, "request_id": 123}' http://127.0.0.1:3000/classify
Test sending request with wrong field name:
$ curl -X POST -H "content-type: application/json" --data '{"sepal_len": 6.2, "sepal_width": 3.2, "petal_len": 5.2, "petal_width_typo": 2.2}' http://127.0.0.1:3000/classify
"BentoService error handling API request: Invalid JSON input received: 2 validation errors for IrisFeatures
petal_width
field required (type=value_error.missing)
petal_width_typo
extra fields not permitted (type=value_error.extra)"%
bentoml build
or with pipenv
pipenv run bentoml build
bentoml containerize iris_classifier_pydantic:latest
or with pipenv
pipenv run bentoml containerize iris_classifier_pydantic:latest