Skip to content

Commit

Permalink
SDK - Compiler - Fixed failures on Jinja placeholders (#2522)
Browse files Browse the repository at this point in the history
Also fixes handling other cases with double curly braces.
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Nov 1, 2019
1 parent 138b072 commit dd1bb7f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions sdk/python/kfp/compiler/_data_passing_rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def fix_big_data_passing(workflow: dict) -> dict:
template_input_to_parent_constant_arguments.setdefault((task_template_name, task_input_name), set()).add(argument_value)

placeholder_type = argument_placeholder_parts[0]
if placeholder_type not in ('inputs', 'outputs', 'tasks', 'steps', 'workflow', 'pod', 'item'):
# Do not fail on Jinja or other double-curly-brace templates
continue
if placeholder_type == 'inputs':
assert argument_placeholder_parts[1] == 'parameters'
dag_input_name = argument_placeholder_parts[2]
Expand Down Expand Up @@ -135,6 +138,9 @@ def fix_big_data_passing(workflow: dict) -> dict:
for placeholder in placeholders:
parts = placeholder.split('.')
placeholder_type = parts[0]
if placeholder_type not in ('inputs', 'outputs', 'tasks', 'steps', 'workflow', 'pod', 'item'):
# Do not fail on Jinja or other double-curly-brace templates
continue
if placeholder_type == 'inputs':
if parts[1] == 'parameters':
input_name = parts[2]
Expand Down Expand Up @@ -162,20 +168,22 @@ def fix_big_data_passing(workflow: dict) -> dict:
for placeholder in placeholders:
parts = placeholder.split('.')
placeholder_type = parts[0]
if placeholder_type not in ('inputs', 'outputs', 'tasks', 'steps', 'workflow', 'pod', 'item'):
# Do not fail on Jinja or other double-curly-brace templates
continue

if placeholder_type == 'workflow' or placeholder_type == 'pod':
pass
elif placeholder_type == 'inputs':
if parts[1] == 'parameters':
input_name = parts[2]
inputs_directly_consumed_as_parameters.add((template_name, input_name))
elif parts[1] == 'artifacts':
raise AssertionError # Should not happen in container templates
raise AssertionError('Found unexpected Argo input artifact placeholder in container template: {}'.format(placeholder))
else:
raise AssertionError
elif placeholder_type == 'outputs':
raise AssertionError # Should not happen in container templates
raise AssertionError('Found unexpected Argo input placeholder in container template: {}'.format(placeholder))
else:
raise AssertionError
raise AssertionError('Found unexpected Argo placeholder in container template: {}'.format(placeholder))

# Finished indexing data consumers

Expand Down

0 comments on commit dd1bb7f

Please sign in to comment.