def b_op( field_x: { 'customized_type': { 'openapi_schema_validator': '{"type": "string", "pattern": "^gcs://.*$"}' } }, field_y: Integer(), field_z: GCSPath() ) -> { 'output_model_uri': 'GcsUri' }: return ContainerOp(name='operator b', image='gcr.io/ml-pipeline/component-a', command=[ 'python3', field_x, ], arguments=[ '--field-y', field_y, '--field-z', field_z, ], file_outputs={ 'output_model_uri': '/schema.txt', })
def b_op( field_x: { 'customized_type': { 'property_a': 'value_a', 'property_b': 'value_b' } }, field_y: Integer(), field_z: GCSPath() ) -> { 'output_model_uri': 'GcsUri' }: return ContainerOp(name='operator b', image='gcr.io/ml-pipeline/component-a', command=[ 'python3', field_x, ], arguments=[ '--field-y', field_y, '--field-z', field_z, ], file_outputs={ 'output_model_uri': '/schema.txt', })
def test_class_to_dict(self): """Test _class_to_dict function.""" gcspath_dict = _instance_to_dict(GCSPath(path_type='file', file_type='csv')) golden_dict = { 'GCSPath': { 'path_type': 'file', 'file_type': 'csv', } } self.assertEqual(golden_dict, gcspath_dict)
def a_op(field_l: Integer()) -> {'field_m': GCSPath(path_type='file', file_type='tsv'), 'field_n': {'customized_type': {'property_a': 'value_a', 'property_b': 'value_b'}}, 'field_o': 'GcsUri'}: return ContainerOp( name = 'operator a', image = 'gcr.io/ml-pipeline/component-a', arguments = [ '--field-l', field_l, ], file_outputs = { 'field_m': '/schema.txt', 'field_n': '/feature.txt', 'field_o': '/output.txt' } )
def test_check_types(self): #Core types typeA = GCSPath(path_type='file', file_type='csv') typeB = GCSPath(path_type='file', file_type='csv') self.assertTrue(check_types(typeA, typeB)) typeC = GCSPath(path_type='file', file_type='tsv') self.assertFalse(check_types(typeA, typeC)) # Custom types typeA = { 'A':{ 'X': 'value1', 'Y': 'value2' } } typeB = { 'B':{ 'X': 'value1', 'Y': 'value2' } } typeC = { 'A':{ 'X': 'value1' } } typeD = { 'A':{ 'X': 'value1', 'Y': 'value3' } } self.assertFalse(check_types(typeA, typeB)) self.assertFalse(check_types(typeA, typeC)) self.assertTrue(check_types(typeC, typeA)) self.assertFalse(check_types(typeA, typeD))
def b_op(field_x, field_y: Integer(), field_z: GCSPath(path_type='file', file_type='tsv')) -> {'output_model_uri': 'GcsUri'}: return ContainerOp( name = 'operator b', image = 'gcr.io/ml-pipeline/component-a', command = [ 'python3', field_x, ], arguments = [ '--field-y', field_y, '--field-z', field_z, ], file_outputs = { 'output_model_uri': '/schema.txt', } )
def componentA(a: {'Schema': {'file_type': 'csv'}}, b: Integer() = 12, c: GCSPath(path_type='file', file_type='tsv') = 'gs://hello/world') -> {'model': Integer()}: return MockContainerOp()
def test_class_to_dict(self): """Test _class_to_dict function.""" gcspath_dict = _instance_to_dict(GCSPath()) golden_dict = {'GCSPath': {}} self.assertEqual(golden_dict, gcspath_dict)