Skip to content

Commit

Permalink
chore(sdk): add test for key error bug resolved in kubeflow#10067
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-mccarthy committed Oct 19, 2023
1 parent 0e240db commit 5863872
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions sdk/python/kfp/compiler/compiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5690,5 +5690,34 @@ def comp() -> List[Artifact]:
return dsl.ContainerSpec(image='alpine', command=['pwd'])


class TestPipelineSpecAttributeUniqueError(unittest.TestCase):

def test_compiles(self):
# in a previous version of the KFP SDK there was an error when:
# - a component has a dsl.OutputPath parameter
# - the pipeline has an existing component by a different name
# - the user calls component.pipeline_spec inside their pipeline definition
# this was resolved coincidentally in
# https://github.com/kubeflow/pipelines/pull/10067, so test that it
# doesn't come back

@dsl.container_component
def existing_comp():
return dsl.ContainerSpec(
image='alpine', command=['echo'], args=['foo'])

@dsl.container_component
def issue_comp(v: dsl.OutputPath(str)):
return dsl.ContainerSpec(image='alpine', command=['echo'], args=[v])

@dsl.pipeline
def my_pipeline():
existing_comp()
issue_comp.pipeline_spec

# should compile without error
self.assertTrue(my_pipeline.pipeline_spec)


if __name__ == '__main__':
unittest.main()

0 comments on commit 5863872

Please sign in to comment.