Update demo of mnist on kfp version 1.8.19

This commit is contained in:
kbthu 2023-05-05 10:30:10 +08:00 committed by GitHub
parent 22dfca63d9
commit 05e507a07f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 0 deletions

8
pipelines-demo/README.md Normal file
View File

@ -0,0 +1,8 @@
# pipelines-demo on Kubeflow/examples
This pipelines-demo contains many examples.
* mnist
* create a volume 'mnist-model' on Kubeflow UI
* compile yaml: python mnist/mnist-example.py
* load mnist-example.py.yaml on Kubeflow UI pipelines

View File

@ -0,0 +1,57 @@
# Copyright 2023 kbthu. All Rights Reserved.
#
# 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.
import kfp
from kfp import dsl
def mnist_train():
cop = dsl.ContainerOp(
name='mnist_train',
image='kbthu/tf-mnist-example:1.0.1',
command=['python3'],
arguments=['/mnist/mnist-train.py'],
file_outputs={'output': '/model/model.keras'},
)
cop.container.set_image_pull_policy('IfNotPresent')
cop.add_pvolumes({'/model': dsl.PipelineVolume(pvc='mnist-model')})
return cop
def mnist_test(model):
cop = dsl.ContainerOp(
name='mnist_test',
image='kbthu/tf-mnist-example:1.0.1',
command=['python3'],
arguments=['/mnist/mnist-test.py'],
)
cop.container.set_image_pull_policy('IfNotPresent')
cop.add_pvolumes({'/model': dsl.PipelineVolume(pvc='mnist-model')})
return cop
@dsl.pipeline(
name='Kubeflow pipeline example',
description='Demonstrate the Kubeflow pipeline with Mnist training'
)
def kfp_example():
_train_op = mnist_train()
mnist_test(
dsl.InputArgumentPath(_train_op.outputs['output'])
).after(_train_op)
if __name__ == '__main__':
import kfp.compiler as compiler
compiler.Compiler().compile(kfp_example, __file__ + '.yaml')