From d83601d19a53c6352370e4365cdcc6697ada33e9 Mon Sep 17 00:00:00 2001 From: Alexey Volkov Date: Fri, 6 Sep 2019 17:05:21 -0700 Subject: [PATCH] SDK - Compiler - Quoting the predicate operands (#2043) Fixes https://github.com/kubeflow/pipelines/issues/1950 --- sdk/python/kfp/compiler/compiler.py | 3 +++ sdk/python/tests/compiler/testdata/coin.yaml | 6 +++--- sdk/python/tests/compiler/testdata/recursive_do_while.yaml | 2 +- sdk/python/tests/compiler/testdata/recursive_while.yaml | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sdk/python/kfp/compiler/compiler.py b/sdk/python/kfp/compiler/compiler.py index 9c86ca59cf..744b254a2d 100644 --- a/sdk/python/kfp/compiler/compiler.py +++ b/sdk/python/kfp/compiler/compiler.py @@ -450,6 +450,9 @@ class Compiler(object): condition = sub_group.condition operand1_value = self._resolve_value_or_reference(condition.operand1, subgroup_inputs) operand2_value = self._resolve_value_or_reference(condition.operand2, subgroup_inputs) + if condition.operator in ['==', '!=']: + operand1_value = '"' + operand1_value + '"' + operand2_value = '"' + operand2_value + '"' task['when'] = '{} {} {}'.format(operand1_value, condition.operator, operand2_value) # Generate dependencies section for this task. diff --git a/sdk/python/tests/compiler/testdata/coin.yaml b/sdk/python/tests/compiler/testdata/coin.yaml index 6e9d5b13a7..577ffb3d76 100644 --- a/sdk/python/tests/compiler/testdata/coin.yaml +++ b/sdk/python/tests/compiler/testdata/coin.yaml @@ -35,7 +35,7 @@ spec: - flip-again name: condition-2 template: condition-2 - when: '{{tasks.flip-again.outputs.parameters.flip-again-output}} == tails' + when: '"{{tasks.flip-again.outputs.parameters.flip-again-output}}" == "tails"' - arguments: parameters: - name: flip-output @@ -119,7 +119,7 @@ spec: - flip name: condition-1 template: condition-1 - when: '{{tasks.flip.outputs.parameters.flip-output}} == heads' + when: '"{{tasks.flip.outputs.parameters.flip-output}}" == "heads"' - arguments: parameters: - name: flip-again-output @@ -131,7 +131,7 @@ spec: - flip name: condition-3 template: condition-3 - when: '{{tasks.flip.outputs.parameters.flip-output}} == tails' + when: '"{{tasks.flip.outputs.parameters.flip-output}}" == "tails"' - name: flip template: flip name: pipeline-flip-coin diff --git a/sdk/python/tests/compiler/testdata/recursive_do_while.yaml b/sdk/python/tests/compiler/testdata/recursive_do_while.yaml index 1c98485fa4..f7c2f4f0f2 100644 --- a/sdk/python/tests/compiler/testdata/recursive_do_while.yaml +++ b/sdk/python/tests/compiler/testdata/recursive_do_while.yaml @@ -75,7 +75,7 @@ spec: - flip-3 name: condition-2 template: condition-2 - when: '{{tasks.flip-3.outputs.parameters.flip-3-output}} == heads' + when: '"{{tasks.flip-3.outputs.parameters.flip-3-output}}" == "heads"' - dependencies: - print name: flip-3 diff --git a/sdk/python/tests/compiler/testdata/recursive_while.yaml b/sdk/python/tests/compiler/testdata/recursive_while.yaml index d7120b53f5..f53bbf996e 100644 --- a/sdk/python/tests/compiler/testdata/recursive_while.yaml +++ b/sdk/python/tests/compiler/testdata/recursive_while.yaml @@ -97,7 +97,7 @@ spec: value: '{{inputs.parameters.maxval}}' name: condition-2 template: condition-2 - when: '{{inputs.parameters.flip-output}} == heads' + when: '"{{inputs.parameters.flip-output}}" == "heads"' inputs: parameters: - name: flip-output