feat(samples): volume ops example to not use container op. Part of #5687 (#5826)

* remove container ops

* clean up

* update with default size
This commit is contained in:
Niklas Hansson 2021-06-10 11:52:51 +02:00 committed by GitHub
parent cc85ca55c6
commit b3c2351a02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -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')