def test_python_component_decorator(self): from kfp.dsl import python_component import kfp.components._python_op as _python_op expected_name = 'Sum component name' expected_description = 'Sum component description' expected_image = 'org/image' @python_component( name=expected_name, description=expected_description, base_image=expected_image ) def add_two_numbers_decorated( a: float, b: float, ) -> float: '''Returns sum of two arguments''' return a + b component_spec = _python_op._func_to_component_spec(add_two_numbers_decorated) self.assertEqual(component_spec.name, expected_name) self.assertEqual(component_spec.description.strip(), expected_description.strip()) self.assertEqual(component_spec.implementation.container.image, expected_image) func = add_two_numbers_decorated op = comp.func_to_container_op(func) self.helper_test_component_against_func_using_local_call(func, op, arguments={'a': 3, 'b': 5.0})
def test_python_component_decorator(self): from kfp.dsl import python_component import kfp.components._python_op as _python_op expected_name = 'Sum component name' expected_description = 'Sum component description' expected_image = 'org/image' @python_component(name=expected_name, description=expected_description, base_image=expected_image) def add_two_numbers_decorated(a: float, b: float) -> float: '''Returns sum of two arguments''' return a + b component_spec = _python_op._func_to_component_spec(add_two_numbers_decorated) self.assertEqual(component_spec.name, expected_name) self.assertEqual(component_spec.description.strip(), expected_description.strip()) self.assertEqual(component_spec.implementation.container.image, expected_image)