-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing caching on maptasks when using partials (#4344)
* adding non-collection literals to statis input readers for cache key computation Signed-off-by: Daniel Rammer <[email protected]> * fixed codespell and added unit tests Signed-off-by: Daniel Rammer <[email protected]> --------- Signed-off-by: Daniel Rammer <[email protected]>
- Loading branch information
Showing
4 changed files
with
188 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
flytepropeller/pkg/controller/nodes/array/node_execution_context_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package array | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/golang/protobuf/proto" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" | ||
) | ||
|
||
var ( | ||
literalOne = &core.Literal{ | ||
Value: &core.Literal_Scalar{ | ||
Scalar: &core.Scalar{ | ||
Value: &core.Scalar_Primitive{ | ||
Primitive: &core.Primitive{ | ||
Value: &core.Primitive_Integer{ | ||
Integer: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
literalTwo = &core.Literal{ | ||
Value: &core.Literal_Scalar{ | ||
Scalar: &core.Scalar{ | ||
Value: &core.Scalar_Primitive{ | ||
Primitive: &core.Primitive{ | ||
Value: &core.Primitive_Integer{ | ||
Integer: 2, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
) | ||
|
||
func TestConstructLiteralMap(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
inputLiteralMaps *core.LiteralMap | ||
expectedLiteralMaps []*core.LiteralMap | ||
}{ | ||
{ | ||
"SingleList", | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": &core.Literal{ | ||
Value: &core.Literal_Collection{ | ||
Collection: &core.LiteralCollection{ | ||
Literals: []*core.Literal{ | ||
literalOne, | ||
literalTwo, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
[]*core.LiteralMap{ | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": literalOne, | ||
}, | ||
}, | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": literalTwo, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
"MultiList", | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": &core.Literal{ | ||
Value: &core.Literal_Collection{ | ||
Collection: &core.LiteralCollection{ | ||
Literals: []*core.Literal{ | ||
literalOne, | ||
literalTwo, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"bar": &core.Literal{ | ||
Value: &core.Literal_Collection{ | ||
Collection: &core.LiteralCollection{ | ||
Literals: []*core.Literal{ | ||
literalTwo, | ||
literalOne, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
[]*core.LiteralMap{ | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": literalOne, | ||
"bar": literalTwo, | ||
}, | ||
}, | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": literalTwo, | ||
"bar": literalOne, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
"Partial", | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": &core.Literal{ | ||
Value: &core.Literal_Collection{ | ||
Collection: &core.LiteralCollection{ | ||
Literals: []*core.Literal{ | ||
literalOne, | ||
literalTwo, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"bar": literalTwo, | ||
}, | ||
}, | ||
[]*core.LiteralMap{ | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": literalOne, | ||
"bar": literalTwo, | ||
}, | ||
}, | ||
&core.LiteralMap{ | ||
Literals: map[string]*core.Literal{ | ||
"foo": literalTwo, | ||
"bar": literalTwo, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
for i := 0; i < len(test.expectedLiteralMaps); i++ { | ||
outputLiteralMap, err := constructLiteralMap(test.inputLiteralMaps, i) | ||
assert.NoError(t, err) | ||
assert.True(t, proto.Equal(test.expectedLiteralMaps[i], outputLiteralMap)) | ||
} | ||
}) | ||
} | ||
} |