From b3c2351a02231f02ecb3f144d3bade06d854ad18 Mon Sep 17 00:00:00 2001 From: Niklas Hansson Date: Thu, 10 Jun 2021 11:52:51 +0200 Subject: [PATCH] feat(samples): volume ops example to not use container op. Part of #5687 (#5826) * remove container ops * clean up * update with default size --- samples/core/volume_ops/volume_ops.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/samples/core/volume_ops/volume_ops.py b/samples/core/volume_ops/volume_ops.py index 98ec66db4b..91652fa4f3 100644 --- a/samples/core/volume_ops/volume_ops.py +++ b/samples/core/volume_ops/volume_ops.py @@ -14,27 +14,28 @@ import kfp import kfp.dsl as dsl +from kfp import components + +@components.create_component_from_func +def write_to_volume(): + with open("/mnt/file.txt", "w") as file: + file.write("Hello world") @dsl.pipeline( name="volumeop-basic", description="A Basic Example on VolumeOp Usage." ) -def volumeop_basic(size): +def volumeop_basic(size: str="1Gi"): vop = dsl.VolumeOp( name="create-pvc", resource_name="my-pvc", modes=dsl.VOLUME_MODE_RWO, size=size ) + + write_to_volume().add_pvolumes({"/mnt'": vop.volume}) - cop = dsl.ContainerOp( - name="cop", - image="library/bash:4.4.23", - command=["sh", "-c"], - arguments=["echo foo > /mnt/file1"], - pvolumes={"/mnt": vop.volume} - ) if __name__ == '__main__': kfp.compiler.Compiler().compile(volumeop_basic, __file__ + '.yaml')