From 51aaa7f3fee8e2ff2fa1809b6914b245b52d7ae9 Mon Sep 17 00:00:00 2001 From: Alexey Volkov Date: Fri, 30 Nov 2018 22:58:44 -0800 Subject: [PATCH] SDK/Components - Renamed container.arguments to container.args This aligns us with Kubernetes spec --- sdk/python/kfp/compiler/_component_builder.py | 2 +- sdk/python/kfp/components/_components.py | 2 +- sdk/python/kfp/components/_python_op.py | 2 +- sdk/python/kfp/components/_structures.py | 12 ++++---- .../tests/components/test_components.py | 28 +++++++++---------- .../test_data/python_add.component.yaml | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/sdk/python/kfp/compiler/_component_builder.py b/sdk/python/kfp/compiler/_component_builder.py index 373ddc5d0d4..7e0cfcda9b5 100644 --- a/sdk/python/kfp/compiler/_component_builder.py +++ b/sdk/python/kfp/compiler/_component_builder.py @@ -440,7 +440,7 @@ def _generate_pythonop(component_func, target_image, target_component_file=None) container=ContainerSpec( image=target_image, #command=['python3', program_file], #TODO: Include the command line - arguments=[{'value': input_name} for input_name in input_names], + args=[{'value': input_name} for input_name in input_names], file_outputs={ #TODO: Use proper output arguments (e.g. "{output: output_name}" ) instead of this workaround. Our 1st-party components should not be using the file_outputs workaround. output_name: output_file, } diff --git a/sdk/python/kfp/components/_components.py b/sdk/python/kfp/components/_components.py index 8f08a69c3bc..f7843aac10c 100644 --- a/sdk/python/kfp/components/_components.py +++ b/sdk/python/kfp/components/_components.py @@ -340,7 +340,7 @@ def expand_argument_list(argument_list): return expanded_list expanded_command = expand_argument_list(container_spec.command) - expanded_args = expand_argument_list(container_spec.arguments) + expanded_args = expand_argument_list(container_spec.args) #Working around Python's variable scoping. Do not write to variable from global scope as that makes the variable local. diff --git a/sdk/python/kfp/components/_python_op.py b/sdk/python/kfp/components/_python_op.py index 0b2fc3ecf0e..44fed3d46f4 100644 --- a/sdk/python/kfp/components/_python_op.py +++ b/sdk/python/kfp/components/_python_op.py @@ -232,7 +232,7 @@ def annotation_to_argument_kind_and_type_name(annotation): container=ContainerSpec( image=base_image, command=['python3', '-c', full_source], - arguments=arguments, + args=arguments, ) ) ) diff --git a/sdk/python/kfp/components/_structures.py b/sdk/python/kfp/components/_structures.py index 2c6f420bbb5..052e8002bf2 100644 --- a/sdk/python/kfp/components/_structures.py +++ b/sdk/python/kfp/components/_structures.py @@ -111,12 +111,12 @@ class OutputSpec(InputOrOutputSpec): class ContainerSpec: - def __init__(self, image:str, command:List=None, arguments:List=None, file_outputs:Mapping[str,str]=None): + def __init__(self, image:str, command:List=None, args:List=None, file_outputs:Mapping[str,str]=None): if not isinstance(image, str): raise ValueError('image must be a string') self.image = image self.command = command - self.arguments = arguments + self.args = args self.file_outputs = file_outputs @staticmethod @@ -129,8 +129,8 @@ def from_struct(spec_dict:Mapping): if 'command' in spec_dict: container_spec.command = list(spec_dict.pop('command')) - if 'arguments' in spec_dict: - container_spec.arguments = list(spec_dict.pop('arguments')) + if 'args' in spec_dict: + container_spec.args = list(spec_dict.pop('args')) if 'fileOutputs' in spec_dict: container_spec.file_outputs = dict(spec_dict.pop('fileOutputs')) @@ -145,8 +145,8 @@ def to_struct(self): struct['image'] = self.image if self.command: struct['command'] = self.command - if self.arguments: - struct['arguments'] = self.arguments + if self.args: + struct['args'] = self.args if self.file_outputs: struct['fileOutputs'] = self.file_outputs diff --git a/sdk/python/tests/components/test_components.py b/sdk/python/tests/components/test_components.py index 182a4bd1f25..3f889b884a5 100644 --- a/sdk/python/tests/components/test_components.py +++ b/sdk/python/tests/components/test_components.py @@ -184,8 +184,8 @@ def test_fail_on_unknown_value_argument(self): implementation: container: image: busybox - arguments: - - [value, Wrong] + args: + - {value: Wrong} ''' task_factory1 = comp.load_component_from_text(component_text) @@ -231,7 +231,7 @@ def test_command_yaml_types(self): implementation: container: image: busybox - arguments: + args: # Nulls: - null #A null - #Also a null @@ -292,7 +292,7 @@ def test_input_value_resolving(self): implementation: container: image: busybox - arguments: + args: - --data - value: Data ''' @@ -308,7 +308,7 @@ def test_output_resolving(self): implementation: container: image: busybox - arguments: + args: - --output-data - output: Data ''' @@ -324,7 +324,7 @@ def test_automatic_output_resolving(self): implementation: container: image: busybox - arguments: + args: - --output-data - {output: Data} ''' @@ -396,7 +396,7 @@ def test_command_concat(self): implementation: container: image: busybox - arguments: + args: - concat: [{value: In1}, {value: In2}] ''' task_factory1 = comp.load_component(text=component_text) @@ -409,7 +409,7 @@ def test_command_if_boolean_true_then_else(self): implementation: container: image: busybox - arguments: + args: - if: cond: true then: --true-arg @@ -424,7 +424,7 @@ def test_command_if_boolean_false_then_else(self): implementation: container: image: busybox - arguments: + args: - if: cond: false then: --true-arg @@ -439,7 +439,7 @@ def test_command_if_true_string_then_else(self): implementation: container: image: busybox - arguments: + args: - if: cond: 'true' then: --true-arg @@ -454,7 +454,7 @@ def test_command_if_false_string_then_else(self): implementation: container: image: busybox - arguments: + args: - if: cond: 'false' then: --true-arg @@ -472,7 +472,7 @@ def test_command_if_is_present_then(self): implementation: container: image: busybox - arguments: + args: - if: cond: {isPresent: In} then: [--in, {value: In}] @@ -493,7 +493,7 @@ def test_command_if_is_present_then_else(self): implementation: container: image: busybox - arguments: + args: - if: cond: {isPresent: In} then: [--in, {value: In}] @@ -517,7 +517,7 @@ def test_command_if_input_value_then(self): implementation: container: image: busybox - arguments: + args: - if: cond: {value: Do test} then: [--test-data, {value: Test data}, --test-param1, {value: Test parameter 1}] diff --git a/sdk/python/tests/components/test_data/python_add.component.yaml b/sdk/python/tests/components/test_data/python_add.component.yaml index 52779f884ef..ffc477845c8 100644 --- a/sdk/python/tests/components/test_data/python_add.component.yaml +++ b/sdk/python/tests/components/test_data/python_add.component.yaml @@ -29,7 +29,7 @@ implementation: import fire fire.Fire(add_wrapper) - arguments: + args: - {value: a} - {value: b} - {output: Output}