Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
fix: strip outputs + test
Browse files Browse the repository at this point in the history
Signed-off-by: Kenny Workman <kennyworkman@sbcglobal.net>
  • Loading branch information
kennyworkman committed Dec 9, 2021
1 parent 43a557e commit efb424d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 12 deletions.
Binary file not shown.
24 changes: 18 additions & 6 deletions pkg/compiler/transformers/k8s/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,26 @@ func buildTasks(tasks []*core.CompiledTask, errs errors.CompileErrors) map[commo

// We don't want Annotation data available at task runtime for performance.
if flyteTask.Template != nil &&
flyteTask.Template.Interface != nil &&
flyteTask.Template.Interface.Inputs != nil &&
flyteTask.Template.Interface.Inputs.Variables != nil {
for _, v := range flyteTask.Template.Interface.Inputs.Variables {
if v.Type != nil && v.Type.Annotation != nil {
v.Type.Annotation = nil
flyteTask.Template.Interface != nil {

if flyteTask.Template.Interface.Inputs != nil &&
flyteTask.Template.Interface.Inputs.Variables != nil {
for _, v := range flyteTask.Template.Interface.Inputs.Variables {
if v.Type != nil && v.Type.Annotation != nil {
v.Type.Annotation = nil
}
}
}

if flyteTask.Template.Interface.Outputs != nil &&
flyteTask.Template.Interface.Outputs.Variables != nil {
for _, v := range flyteTask.Template.Interface.Outputs.Variables {
if v.Type != nil && v.Type.Annotation != nil {
v.Type.Annotation = nil
}
}
}

}

res[taskID] = &v1alpha1.TaskSpec{TaskTemplate: flyteTask.Template}
Expand Down
38 changes: 32 additions & 6 deletions pkg/compiler/transformers/k8s/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func TestBuildTasks(t *testing.T) {
tasks := []*core.CompiledTask{
{
Template: &core.TaskTemplate{
Id: &core.Identifier{Name: "annotated"},
Id: &core.Identifier{Name: "annotatedInput"},
Interface: &core.TypedInterface{
Inputs: &core.VariableMap{
Variables: withAnnotations,
Expand All @@ -244,25 +244,51 @@ func TestBuildTasks(t *testing.T) {
},
{
Template: &core.TaskTemplate{
Id: &core.Identifier{Name: "unannotated"},
Id: &core.Identifier{Name: "unannotatedInput"},
Interface: &core.TypedInterface{
Inputs: &core.VariableMap{
Variables: withoutAnnotations,
},
},
},
},
{
Template: &core.TaskTemplate{
Id: &core.Identifier{Name: "annotatedOutput"},
Interface: &core.TypedInterface{
Outputs: &core.VariableMap{
Variables: withAnnotations,
},
},
},
},
{
Template: &core.TaskTemplate{
Id: &core.Identifier{Name: "unannotatedOutput"},
Interface: &core.TypedInterface{
Outputs: &core.VariableMap{
Variables: withoutAnnotations,
},
},
},
},
}

errs := errors.NewCompileErrors()

t.Run("Tasks with annotations", func(t *testing.T) {
taskMap := buildTasks(tasks, errs)

annTask := taskMap[(&core.Identifier{Name: "annotated"}).String()]
assert.Nil(t, annTask.Interface.Inputs.Variables["a"].Type.Annotation)
annInputTask := taskMap[(&core.Identifier{Name: "annotatedInput"}).String()]
assert.Nil(t, annInputTask.Interface.Inputs.Variables["a"].Type.Annotation)

unAnnInputTask := taskMap[(&core.Identifier{Name: "unannotatedInput"}).String()]
assert.Nil(t, unAnnInputTask.Interface.Inputs.Variables["a"].Type.Annotation)

annOutputTask := taskMap[(&core.Identifier{Name: "annotatedOutput"}).String()]
assert.Nil(t, annOutputTask.Interface.Outputs.Variables["a"].Type.Annotation)

unAnnTask := taskMap[(&core.Identifier{Name: "annotated"}).String()]
assert.Nil(t, unAnnTask.Interface.Inputs.Variables["a"].Type.Annotation)
unAnnOutputTask := taskMap[(&core.Identifier{Name: "unannotatedOutput"}).String()]
assert.Nil(t, unAnnOutputTask.Interface.Outputs.Variables["a"].Type.Annotation)
})
}

0 comments on commit efb424d

Please sign in to comment.