diff --git a/pkg/compiler/test/compiler_test.go b/pkg/compiler/test/compiler_test.go index 8a2518ee9..8e6f1da3c 100644 --- a/pkg/compiler/test/compiler_test.go +++ b/pkg/compiler/test/compiler_test.go @@ -189,9 +189,9 @@ func TestBranches(t *testing.T) { t.Run(path, func(t *testing.T) { // If you want to debug a single use-case. Uncomment this line. - //if !strings.HasSuffix(path, "success_1.json") { - // t.SkipNow() - //} + if !strings.HasSuffix(path, "success_7.json") { + t.SkipNow() + } raw, err := ioutil.ReadFile(path) assert.NoError(t, err) diff --git a/pkg/compiler/test/testdata/branch/success_7.json b/pkg/compiler/test/testdata/branch/success_7.json new file mode 100644 index 000000000..197a6ba9b --- /dev/null +++ b/pkg/compiler/test/testdata/branch/success_7.json @@ -0,0 +1,214 @@ +{ + "workflow": { + "id": { + "resourceType": "WORKFLOW", + "project": "project", + "domain": "domain", + "name": "name", + "version": "version" + }, + "metadata": {}, + "interface": { + "inputs": { + "variables": { + "my_input": { + "type": { + "simple": "FLOAT" + }, + "description": "my_input" + } + } + }, + "outputs": { + "variables": { + "o0": { + "type": { + "simple": "FLOAT" + }, + "description": "o0" + } + } + } + }, + "nodes": [ + { + "id": "node-0", + "metadata": {}, + "inputs": [ + { + "var": ".var-1", + "binding": { + "promise": { + "var": "my_input", + "nodeId": "start-node" + } + } + }, + { + "var": ".var-2", + "binding": { + "promise": { + "var": "my_input", + "nodeId": "start-node" + } + } + }, + { + "var": "n", + "binding": { + "promise": { + "var": "my_input", + "nodeId": "start-node" + } + } + } + ], + "branchNode": { + "ifElse": { + "case": { + "condition": { + "comparison": { + "operator": "EQ", + "leftValue": { + "var": ".var-1" + }, + "rightValue": { + "var": ".var-1" + } + } + }, + "thenNode": { + "id": "thenNode-1", + "metadata": {}, + "inputs": [ + { + "var": ".var-1", + "binding": { + "promise": { + "var": "my_input", + "nodeId": "start-node" + } + } + } + ], + "branchNode": { + "ifElse": { + "case": { + "condition": { + "comparison": { + "operator": "EQ", + "leftValue": { + "var": ".var-2" + }, + "rightValue": { + "var": ".var-2" + } + } + }, + "thenNode": { + "id": "thenNode-2", + "metadata": {}, + "inputs": [ + { + "var": "n", + "binding": { + "promise": { + "var": "my_input", + "nodeId": "start-node" + } + } + } + ], + "taskNode": { + "referenceId": { + "resourceType": "TASK", + "project": "project", + "domain": "domain", + "name": "name", + "version": "version" + } + } + } + }, + "error": { + "message": "", + "failedNodeId": "" + } + } + } + } + }, + "error": { + "message": "", + "failedNodeId": "" + } + } + } + } + ], + "outputs": [ + { + "var": "o0", + "binding": { + "promise": { + "nodeId": "node-0", + "var": "o0" + } + } + } + ], + "metadataDefaults": {} + }, + "tasks": [ + { + "id": { + "resourceType": "TASK", + "project": "project", + "domain": "domain", + "name": "name", + "version": "version" + }, + "type": "python-task", + "metadata": {}, + "interface": { + "inputs": { + "variables": { + "n": { + "type": { + "simple": "FLOAT" + }, + "description": "n" + }, + ".var-1": { + "type": { + "simple": "FLOAT" + }, + "description": ".var-1" + }, + ".var-2": { + "type": { + "simple": "FLOAT" + }, + "description": ".var-2" + } + } + }, + "outputs": { + "variables": { + "o0": { + "type": { + "simple": "FLOAT" + }, + "description": "o0" + } + } + } + }, + "container": { + "image": "image:name", + "args": ["command"], + "resources": {} + } + } + ] +} diff --git a/pkg/compiler/validators/branch.go b/pkg/compiler/validators/branch.go index 536626258..d58a7a672 100644 --- a/pkg/compiler/validators/branch.go +++ b/pkg/compiler/validators/branch.go @@ -67,20 +67,20 @@ func validateBranchInterface(w c.WorkflowBuilder, node c.NodeBuilder, errs error if iface, ok = ValidateUnderlyingInterface(w, n, errs.NewScope()); ok { // Clear out the Inputs. We do not care if the inputs of each of the underlying nodes // match. We will pull the inputs needed for the underlying branch node at runtime. - iface = &flyte.TypedInterface{ - Inputs: &flyte.VariableMap{Variables: map[string]*flyte.Variable{}}, - Outputs: iface.Outputs, - } + // iface = &flyte.TypedInterface{ + // Inputs: &flyte.VariableMap{Variables: map[string]*flyte.Variable{}}, + // Outputs: iface.Outputs, + // } outputs, outputsSet = buildVariablesIndex(iface.Outputs) finalOutputParameterNames = finalOutputParameterNames.Union(outputsSet) } } else { if iface2, ok2 := ValidateUnderlyingInterface(w, n, errs.NewScope()); ok2 { - iface2 = &flyte.TypedInterface{ - Inputs: &flyte.VariableMap{Variables: map[string]*flyte.Variable{}}, - Outputs: iface2.Outputs, - } + //iface2 = &flyte.TypedInterface{ + // Inputs: &flyte.VariableMap{Variables: map[string]*flyte.Variable{}}, + // Outputs: iface2.Outputs, + //} validateIfaceMatch(n.GetId(), iface2, errs.NewScope()) } @@ -88,10 +88,15 @@ func validateBranchInterface(w c.WorkflowBuilder, node c.NodeBuilder, errs error } if !errs.HasErrors() && iface != nil { + print(finalOutputParameterNames) + print(finalInputParameterNames) + /* iface = &flyte.TypedInterface{ Inputs: filterVariables(iface.Inputs, finalInputParameterNames), Outputs: filterVariables(iface.Outputs, finalOutputParameterNames), } + */ + iface = iface } else { iface = nil } diff --git a/pkg/compiler/validators/node.go b/pkg/compiler/validators/node.go index f8d314181..2279bf6f0 100644 --- a/pkg/compiler/validators/node.go +++ b/pkg/compiler/validators/node.go @@ -133,12 +133,12 @@ func ValidateNode(w c.WorkflowBuilder, n c.NodeBuilder, validateConditionTypes b if n.GetBranchNode() != nil { if nodes, edges, ok := ValidateBranchNode(w, n, validateConditionTypes, errs.NewScope()); ok { renamedNodes := make(map[c.NodeID]c.NodeID, len(nodes)) - for _, subNode := range nodes { - oldID := subNode.GetId() - subNode.SetID(branchNodeIDFormatter(n.GetId(), subNode.GetId())) - w.AddNode(subNode, errs) - renamedNodes[oldID] = subNode.GetId() - } + //for _, subNode := range nodes { + // oldID := subNode.GetId() + // subNode.SetID(branchNodeIDFormatter(n.GetId(), subNode.GetId())) + // w.AddNode(subNode, errs) + // renamedNodes[oldID] = subNode.GetId() + //} for _, edge := range edges { if newID, found := renamedNodes[edge.from]; found {