Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ai_platform test #2327

Merged
merged 6 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,41 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"# Required Parameters\n",
"PROJECT_ID = '<ADD GCP PROJECT HERE>'\n",
"GCS_WORKING_DIR = 'gs://<ADD STORAGE LOCATION HERE>' # No ending slash\n",
"\n",
"project_id = '<ADD GCP PROJECT HERE>'\n",
"output = 'gs://<ADD STORAGE LOCATION HERE>' # No ending slash\n",
"experiment_name = 'Chicago Crime Prediction'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Optional Parameters\n",
"REGION = 'us-central1'\n",
"RUNTIME_VERSION = '1.13'\n",
"PACKAGE_URIS=json.dumps(['gs://chicago-crime/chicago_crime_trainer-0.0.tar.gz'])\n",
"TRAINER_OUTPUT_GCS_PATH = GCS_WORKING_DIR + '/train/output/' + str(int(time.time())) + '/'\n",
"DATA_GCS_PATH = GCS_WORKING_DIR + '/reports.csv'\n",
"TRAINER_OUTPUT_GCS_PATH = output + '/train/output/' + str(int(time.time())) + '/'\n",
"DATA_GCS_PATH = output + '/reports.csv'\n",
"PYTHON_MODULE = 'trainer.task'\n",
"TRAINER_ARGS = json.dumps([\n",
" '--data-file-url', DATA_GCS_PATH,\n",
" '--job-dir', GCS_WORKING_DIR\n",
" '--job-dir', output\n",
"])\n",
"EXPERIMENT_NAME = 'Chicago Crime Prediction'\n",
"PIPELINE_NAME = 'Chicago Crime Prediction'\n",
"PIPELINE_FILENAME_PREFIX = 'chicago'\n",
"PIPELINE_DESCRIPTION = ''"
"PIPELINE_DESCRIPTION = ''\n",
"MODEL_NAME = 'chicago_pipeline_model' + str(int(time.time()))\n",
"MODEL_VERSION = 'chicago_pipeline_model_v1' + str(int(time.time()))"
]
},
{
Expand Down Expand Up @@ -191,6 +204,7 @@
" project_id,\n",
" model_uri,\n",
" model_id,\n",
" model_version,\n",
" runtime_version):\n",
" \n",
" return mlengine_deploy_op(\n",
Expand Down Expand Up @@ -222,8 +236,8 @@
"\n",
"def pipeline(\n",
" data_gcs_path=DATA_GCS_PATH,\n",
" gcs_working_dir=GCS_WORKING_DIR,\n",
" project_id=PROJECT_ID,\n",
" gcs_working_dir=output,\n",
" project_id=project_id,\n",
" python_module=PYTHON_MODULE,\n",
" region=REGION,\n",
" runtime_version=RUNTIME_VERSION,\n",
Expand All @@ -245,7 +259,8 @@
" \n",
" deploy_task = deploy(project_id,\n",
" train_task.outputs['job_dir'],\n",
" train_task.outputs['job_id'],\n",
" MODEL_NAME,\n",
" MODEL_VERSION,\n",
" runtime_version) \n",
" return True\n",
"\n",
Expand All @@ -266,11 +281,29 @@
"metadata": {},
"outputs": [],
"source": [
"kfp.Client().create_run_from_pipeline_func(pipeline, arguments={}, experiment_name=EXPERIMENT_NAME)"
"kfp.Client().create_run_from_pipeline_func(pipeline, arguments={}, experiment_name=experiment_name)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Clean models"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!gcloud ml-engine versions delete $MODEL_VERSION --model $MODEL_NAME\n",
"!gcloud ml-engine models delete $MODEL_NAME"
]
}
],
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
Expand All @@ -286,7 +319,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.6.4"
},
"pycharm": {
"stem_cell": {
Expand Down
19 changes: 19 additions & 0 deletions test/sample-test/configs/ai_platform.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

test_name: ai_platform
notebook_params:
output:
project_id: ml-pipeline-test
experiment_name: ai_platform-test
1 change: 1 addition & 0 deletions test/sample_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ spec:
- loop_parameter
- loop_static
- resource_ops
- ai_platform
- parameterized_tfx_oss
# Build and push image
- name: build-image-by-dockerfile
Expand Down