Compare commits

...
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2022 Google LLC\n",
"# Copyright 2021 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -1872,14 +1872,29 @@
" + str(TASK_ID)\n",
" + \"/gcp_resources\"\n",
" )\n",
" EVAL_METRICS = (\n",
" PIPELINE_ROOT\n",
" + \"/\"\n",
" + PROJECT_NUMBER\n",
" + \"/\"\n",
" + JOB_ID\n",
" + \"/\"\n",
" + output_task_name\n",
" + \"_\"\n",
" + str(TASK_ID)\n",
" + \"/evaluation_metrics\"\n",
" )\n",
" if tf.io.gfile.exists(EXECUTE_OUTPUT):\n",
" ! gsutil cat $EXECUTE_OUTPUT\n",
" break\n",
" return EXECUTE_OUTPUT\n",
" elif tf.io.gfile.exists(GCP_RESOURCES):\n",
" ! gsutil cat $GCP_RESOURCES\n",
" break\n",
" return GCP_RESOURCES\n",
" elif tf.io.gfile.exists(EVAL_METRICS):\n",
" ! gsutil cat $EVAL_METRICS\n",
" return EVAL_METRICS\n",
"\n",
" return EXECUTE_OUTPUT\n",
" return None\n",
"\n",
"\n",
"print(\"make-chicago-bq-dataset\")\n",
@@ -2120,7 +2135,9 @@
" region: str = REGION,\n",
" labels: dict = {\"base_model\": \"1\"},\n",
"):\n",
" from google_cloud_pipeline_components import aiplatform as gcc_aip\n",
" from google_cloud_pipeline_components.types import artifact_types\n",
" from google_cloud_pipeline_components.v1.model import ModelUploadOp\n",
" from kfp.v2.components import importer_node\n",
"\n",
" model_build_op = build_model(\n",
" dataset_id=dataset_id,\n",
@@ -2130,14 +2147,21 @@
" project=project,\n",
" )\n",
"\n",
" model_upload_op = gcc_aip.ModelUploadOp(\n",
" display_name=display_name,\n",
" import_unmanaged_model_task = importer_node.importer(\n",
" artifact_uri=model_build_op.output,\n",
" serving_container_image_uri=deploy_image,\n",
" labels=labels,\n",
" artifact_class=artifact_types.UnmanagedContainerModel,\n",
" metadata={\n",
" \"containerSpec\": {\n",
" \"imageUri\": DEPLOY_IMAGE,\n",
" },\n",
" },\n",
" ).after(model_build_op)\n",
"\n",
" model_upload = ModelUploadOp(\n",
" project=project,\n",
" location=region,\n",
" )"
" display_name=display_name,\n",
" unmanaged_container_model=import_unmanaged_model_task.outputs[\"artifact\"],\n",
" ).after(import_unmanaged_model_task)"
]
},
{
@@ -3048,6 +3072,8 @@
" region: str = REGION,\n",
"):\n",
" from google_cloud_pipeline_components import aiplatform as gcc_aip\n",
" from google_cloud_pipeline_components.v1.endpoint import (EndpointCreateOp,\n",
" ModelDeployOp)\n",
"\n",
" with dsl.Condition(warmup == \"True\", name=\"warmup-model\"):\n",
"\n",
@@ -3089,13 +3115,13 @@
" labels=label,\n",
" )\n",
"\n",
" endpoint_op = gcc_aip.EndpointCreateOp(\n",
" endpoint_op = EndpointCreateOp(\n",
" project=project,\n",
" location=region,\n",
" display_name=display_name,\n",
" ).after(training_op)\n",
"\n",
" deploy_op = gcc_aip.ModelDeployOp(\n",
" deploy_op = ModelDeployOp(\n",
" model=training_op.outputs[\"model\"],\n",
" endpoint=endpoint_op.outputs[\"endpoint\"],\n",
" dedicated_resources_min_replica_count=1,\n",