Update sklearn-sentiment-clf.ipynb
")\n",
"\n",
"# Save bentoML model to directory\n",
- "saved_path = bento_model.save(\"/tmp/bento\")\n",
- "\n",
- "# print the directory containing exported model archive (prefixed with model name and version)\n",
- "print(saved_path)"
+ "saved_path = bento_model.save(\"/tmp/bento\")"
]
},
{
"bento_model.predict(pd.Series([\"hello\", \"hi\"]))"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "*For demo purpurse, copy generated model to ./model folder"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "import shutil\n",
- "shutil.rmtree('./model', ignore_errors=True)\n",
- "shutil.copytree(saved_path, './model')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# \"pip install\" a BentoML archive\n",
"\n",
- "BentoML user can directly pip install saved BentoML archive with `pip install $SAVED_PATH`, and use it as a regular python package."
+ "BentoML user can directly pip install saved BentoML archive with `pip install {saved_path}`, and use it as a regular python package."
]
},
{
"metadata": {},
"outputs": [],
"source": [
- "!pip install ./model"
+ "!pip install {saved_path}"
]
},
{
"source": [
"# CLI access\n",
"\n",
- "`pip install ./model` also installs a CLI tool for accessing the BentoML service"
+ "`pip install saved_path` also installs a CLI tool for accessing the BentoML service"
]
},
{
"metadata": {},
"outputs": [],
"source": [
+ "# Run prediction with sample input\n",
"!SentimentLRModel predict --input='[\"some new text, sweet noodles\", \"happy time\", \"sad day\"]'"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# OpenAPI docs for generating API Client\n",
+ "!SentimentLRModel docs"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
"metadata": {},
"outputs": [],
"source": [
- "!bentoml serve ./model"
+ "!bentoml serve {saved_path}"
]
},
{
"metadata": {},
"outputs": [],
"source": [
- "!cd \"./model\" && docker build -t sentiment-lr-model ."
+ "!cd {saved_path} && docker build -t sentiment-lr-model ."
]
},
{
