Skip to content

Commit

Permalink
Add sample test for multiple output (#2328)
Browse files Browse the repository at this point in the history
* add sample test for multiple output

* adjust the output path

* rename config file

* fix param

* remove the python_component decorator
  • Loading branch information
gaoning777 authored and k8s-ci-robot committed Oct 10, 2019
1 parent e89aa48 commit d7f0c1e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,21 @@
},
"outputs": [],
"source": [
"GCS_BUCKET = 'gs://[BUCKET-NAME]' # GCS bucket name\n",
"PROJECT_NAME = '[PROJECT-NAME]' # GCP project name\n",
"\n",
"STAGING_GCS_PATH = GCS_BUCKET + '/multiple-output-sample'\n",
"TARGET_IMAGE = 'gcr.io/%s/multi-output:latest' % PROJECT_NAME\n",
"\n",
"BASE_IMAGE = 'tensorflow/tensorflow:1.11.0-py3'\n",
"EXPERIMENT_NAME = 'Multiple Outputs Sample'"
"output = 'gs://[BUCKET-NAME]' # GCS bucket name\n",
"project_id = '[PROJECT-NAME]' # GCP project name\n",
"experiment_name = 'Multiple Outputs Sample'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"STAGING_GCS_PATH = os.path.join(output, 'multiple-output-sample')\n",
"TARGET_IMAGE = 'gcr.io/%s/multi-output:latest' % project_id\n",
"BASE_IMAGE = 'tensorflow/tensorflow:1.11.0-py3'"
]
},
{
Expand Down Expand Up @@ -86,12 +93,6 @@
"metadata": {},
"outputs": [],
"source": [
"# Returns a*b and a+b\n",
"@dsl.python_component(\n",
" name='product_sum',\n",
" description='Calculates the product and the sum',\n",
" base_image=BASE_IMAGE\n",
")\n",
"def product_sum(a: float, b: float) -> NamedTuple(\n",
" 'output', [('product', float), ('sum', float)]):\n",
" '''Returns the product and sum of two numbers'''\n",
Expand Down Expand Up @@ -160,11 +161,12 @@
" 'b': 2.5,\n",
" 'c': 3.0,\n",
"}\n",
"run_result = kfp.Client().create_run_from_pipeline_func(pipeline, arguments=arguments, experiment_name=EXPERIMENT_NAME)"
"run_result = kfp.Client().create_run_from_pipeline_func(pipeline, arguments=arguments, experiment_name=experiment_name)"
]
}
],
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
Expand All @@ -180,7 +182,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.6.4"
}
},
"nbformat": 4,
Expand Down
19 changes: 19 additions & 0 deletions test/sample-test/configs/multiple_outputs.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: multiple_outputs
notebook_params:
output:
project_id: ml-pipeline-test
experiment_name: multiple_outputs-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
- multiple_outputs
- ai_platform
- parameterized_tfx_oss
# Build and push image
Expand Down

0 comments on commit d7f0c1e

Please sign in to comment.