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

SDK/DSL: ContainerOp.add_pvolume - Fix volume passed in add_volume #2306

Merged
merged 1 commit into from
Oct 5, 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
3 changes: 2 additions & 1 deletion sdk/python/kfp/dsl/_container_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,8 @@ def add_pvolumes(self,
self.dependent_names.extend(pvolume.dependent_names)
else:
pvolume = PipelineVolume(volume=pvolume)
self.pvolumes[mount_path] = pvolume.after(self)
pvolume = pvolume.after(self)
self.pvolumes[mount_path] = pvolume
self.add_volume(pvolume)
self._container.add_volume_mount(V1VolumeMount(
name=pvolume.name,
Expand Down
11 changes: 10 additions & 1 deletion sdk/python/tests/dsl/container_op_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from kubernetes.client.models import V1EnvVar, V1VolumeMount

import kfp
from kfp.dsl import ContainerOp, UserContainer, Sidecar
from kfp.dsl import ContainerOp, UserContainer, Sidecar, PipelineVolume


class TestContainerOp(unittest.TestCase):
Expand Down Expand Up @@ -89,3 +89,12 @@ def test_deprecation_warnings(self):
op.add_volume_mount(V1VolumeMount(
mount_path='/secret/gcp-credentials',
name='gcp-credentials'))


def test_add_pvolumes(self):
pvolume = PipelineVolume(pvc='test')
op = ContainerOp(name='op1', image='image', pvolumes={'/mnt': pvolume})

self.assertEqual(pvolume.dependent_names, [])
self.assertEqual(op.pvolume.dependent_names, [op.name])
self.assertEqual(op.volumes[0].dependent_names, [op.name])