GoogleCloudPlatform / mlops-with-vertex-ai

An end-to-end example of MLOps on Google Cloud using TensorFlow, TFX, and Vertex AI
Apache License 2.0
341 stars 115 forks source link

Unit test for pipeline in Vertex AI #20

Open RobertWan91 opened 2 years ago

RobertWan91 commented 2 years ago

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,

glema-xmartlabs commented 7 months ago

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'