def test_to_placeholder(self): structure = structures.InputUriPlaceholder('input1') actual = structure.to_placeholder() expected = "{{$.inputs.artifacts['input1'].uri}}" self.assertEqual( actual, expected, )
def test_from_placeholder(self): placeholder = "{{$.inputs.artifacts['input1'].uri}}" expected = structures.InputUriPlaceholder('input1') actual = structures.InputUriPlaceholder.from_placeholder(placeholder) self.assertEqual( actual, expected, )
def _transform_arg(arg: ValidCommandArgs) -> Any: if isinstance(arg, str): return arg if isinstance(arg, InputValuePlaceholder): return v1_structures.InputValuePlaceholder(arg.input_name) if isinstance(arg, InputPathPlaceholder): return v1_structures.InputPathPlaceholder(arg.input_name) if isinstance(arg, InputUriPlaceholder): return v1_structures.InputUriPlaceholder(arg.input_name) if isinstance(arg, OutputPathPlaceholder): return v1_structures.OutputPathPlaceholder(arg.output_name) if isinstance(arg, OutputUriPlaceholder): return v1_structures.OutputUriPlaceholder(arg.output_name) if isinstance(arg, IfPresentPlaceholder): return v1_structures.IfPlaceholder(arg.if_structure) if isinstance(arg, ConcatPlaceholder): return v1_structures.ConcatPlaceholder(arg.concat) raise ValueError( f'Unexpected command/argument type: "{arg}" of type "{type(arg)}".' )
def test_input_uri_placeholder(self): arg = "{{$.inputs.artifacts['input1'].uri}}" actual = structures.maybe_convert_command_arg_to_placeholder(arg) expected = structures.InputUriPlaceholder('input1') self.assertEqual(actual, expected)
- {name: optional_input_1, optional: true, type: String} name: component_if """) COMPONENT_SPEC_IF_PLACEHOLDER = structures.ComponentSpec( name='component_if', implementation=structures.Implementation( container=structures.ContainerSpec( image='alpine', args=[ structures.IfPresentPlaceholder( if_structure=structures.IfPresentPlaceholderStructure( input_name='optional_input_1', then=[ '--arg1', structures.InputUriPlaceholder( input_name='optional_input_1'), ], otherwise=[ '--arg2', 'default', ])) ])), inputs={ 'optional_input_1': structures.InputSpec(type='String', default=None) }, ) V1_YAML_CONCAT_PLACEHOLDER = textwrap.dedent("""\ name: component_concat implementation: container: