Compare commits

...
@@ -670,6 +670,56 @@
"print(\"Train machine type\", DEPLOY_COMPUTE)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8ac30ffa72b5"
},
"source": [
"### Create the instance schema\n",
"\n",
"The instance.yaml file is used to validate the format of the input request before it goes to the model server. If you are sending correctly you don't need instance.yaml. If you get bad requests, the instance.yaml will give a more meaningful error msg than what you probably get from the model server.\n",
"\n",
"*The instance.yaml can also be reused as the input schema for Model Monitoring custom models.*\n",
"\n",
"\n",
"\n",
"Learn more about [Predict schemas](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/PredictSchemata)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "59becb56ad34"
},
"outputs": [],
"source": [
"yaml = \"\"\"type: array\n",
"properties:\n",
" sepal_length:\n",
" type: numeric\n",
" sepal_width:\n",
" type: numeric\n",
" petal_length:\n",
" type: numeric\n",
" petal_width:\n",
" type: numeric\n",
"required:\n",
" - sepal_length\n",
" - sepal_width\n",
" - petal_length\n",
" - petal_width\n",
"\"\"\"\n",
"\n",
"print(yaml)\n",
"\n",
"with open(\"instance.yaml\", \"w\") as f:\n",
" f.write(yaml)\n",
"\n",
"! gsutil cp instance.yaml {BUCKET_URI}/instance.yaml"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -709,6 +759,7 @@
" display_name=f\"xgboost_iris_{UUID}\",\n",
" serving_container_image_uri=DEPLOY_IMAGE,\n",
" artifact_uri=MODEL_ARTIFACTS,\n",
" instance_schema_uri=f\"{BUCKET_URI}/instance.yaml\",\n",
" is_default_version=True,\n",
" version_aliases=[\"v1\", \"version1\"],\n",
" version_description=\"This is the first version of the model\",\n",
@@ -749,7 +800,7 @@
"outputs": [],
"source": [
"endpoint = aiplatform.Endpoint.create(\n",
" display_name=\"flowers_\" + UUID,\n",
" display_name=\"xgboost_iris_\" + UUID,\n",
" project=PROJECT_ID,\n",
" location=REGION,\n",
" labels={\"your_key\": \"your_value\"},\n",