mlops-with-vertex-ai icon indicating copy to clipboard operation
mlops-with-vertex-ai copied to clipboard

Unit test for pipeline in Vertex AI

Open RobertWan91 opened this issue 2 years ago • 1 comments

After reading the notebook: https://github.com/GoogleCloudPlatform/mlops-with-vertex-ai/blob/main/04-pipeline-deployment.ipynb

the unit test is testing the functions which is not used to launch the pipeline. It seems that there are two sets of functions, one for unit test and one for createing pipeline. Is that possible to test the functions defined under @component decorators?

Many thanks,

RobertWan91 avatar Apr 22 '22 04:04 RobertWan91

To access the function defined under the @component you need to get its python_func attribute. So if you have a function:

@component
def foo():
  return 'foo'

Then you can test it like this:

def test_foo():
  assert foo.python_func() == 'foo'

glema-xmartlabs avatar Nov 14 '23 20:11 glema-xmartlabs