fix(sdk): fix load v1 if present placeholder (#7765)
* fix load v1 if present placeholder * add test for load v1 if present placeholder
This commit is contained in:
parent
d25bbc88b1
commit
0cf817364c
|
@ -841,18 +841,20 @@ class ComponentSpec(base_model.BaseModel):
|
|||
input_name=utils.sanitize_input_name(
|
||||
if_placeholder_values['cond']['isPresent']),
|
||||
then=[
|
||||
convert_str_or_dict_to_placeholder(val)
|
||||
convert_str_or_dict_to_placeholder(
|
||||
convert_v1_if_present_placholder_to_v2(val))
|
||||
for val in if_placeholder_values_then
|
||||
],
|
||||
otherwise=[
|
||||
convert_str_or_dict_to_placeholder(val)
|
||||
convert_str_or_dict_to_placeholder(
|
||||
convert_v1_if_present_placholder_to_v2(val))
|
||||
for val in if_placeholder_values_else
|
||||
]))
|
||||
|
||||
elif 'concat' in arg:
|
||||
|
||||
return ConcatPlaceholder(items=[
|
||||
convert_str_or_dict_to_placeholder(val)
|
||||
convert_str_or_dict_to_placeholder(
|
||||
convert_v1_if_present_placholder_to_v2(val))
|
||||
for val in arg['concat']
|
||||
])
|
||||
elif isinstance(arg, (ValidCommandArgTypes, dict)):
|
||||
|
|
|
@ -91,6 +91,30 @@ COMPONENT_SPEC_CONCAT_PLACEHOLDER = structures.ComponentSpec(
|
|||
inputs={'input_prefix': structures.InputSpec(type='String')},
|
||||
)
|
||||
|
||||
V1_YAML_NESTED_PLACEHOLDER = textwrap.dedent("""\
|
||||
name: component_nested
|
||||
implementation:
|
||||
container:
|
||||
args:
|
||||
- concat:
|
||||
- --arg1
|
||||
- if:
|
||||
cond:
|
||||
isPresent: input_prefix
|
||||
else:
|
||||
- --arg2
|
||||
- default
|
||||
- concat:
|
||||
- --arg1
|
||||
- {inputValue: input_prefix}
|
||||
then:
|
||||
- --arg1
|
||||
- {inputValue: input_prefix}
|
||||
image: alpine
|
||||
inputs:
|
||||
- {name: input_prefix, optional: false, type: String}
|
||||
""")
|
||||
|
||||
COMPONENT_SPEC_NESTED_PLACEHOLDER = structures.ComponentSpec(
|
||||
name='component_nested',
|
||||
implementation=structures.Implementation(
|
||||
|
@ -287,6 +311,10 @@ sdkVersion: kfp-2.0.0-alpha.2
|
|||
'yaml': V1_YAML_CONCAT_PLACEHOLDER,
|
||||
'expected_component': COMPONENT_SPEC_CONCAT_PLACEHOLDER
|
||||
},
|
||||
{
|
||||
'yaml': V1_YAML_NESTED_PLACEHOLDER,
|
||||
'expected_component': COMPONENT_SPEC_NESTED_PLACEHOLDER
|
||||
},
|
||||
)
|
||||
def test_component_spec_placeholder_load_from_v2_component_yaml(
|
||||
self, yaml, expected_component):
|
||||
|
|
Loading…
Reference in New Issue