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

Commit

Permalink
Update flyteplugins (#578)
Browse files Browse the repository at this point in the history
* Update `flyteplugins`

Signed-off-by: Bernhard Stadlbauer <[email protected]>

* Update `flytepropeller`

Signed-off-by: Bernhard Stadlbauer <[email protected]>

* Fix imports

Signed-off-by: Bernhard Stadlbauer <[email protected]>

* Bump flyteplugins to v1.1.7

Signed-off-by: Bernhard Stadlbauer <[email protected]>

* Return `err` instead of `nil`

Signed-off-by: Bernhard Stadlbauer <[email protected]>

---------

Signed-off-by: Bernhard Stadlbauer <[email protected]>
Co-authored-by: Dan Rammer <[email protected]>
  • Loading branch information
bstadlbauer and hamersaw authored Jul 5, 2023
1 parent 1541ae5 commit 357bf09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 640 deletions.
64 changes: 1 addition & 63 deletions pkg/controller/nodes/task/catalog/datacatalog/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import (
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/datacatalog"
"github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/catalog"

"github.com/flyteorg/flytepropeller/pkg/compiler/validators"

"github.com/flyteorg/flytestdlib/pbhash"
)

Expand Down Expand Up @@ -116,72 +114,12 @@ func generateTaskSignatureHash(ctx context.Context, taskInterface core.TypedInte
return fmt.Sprintf("%v-%v", inputHashString, outputHashString), nil
}

// Hashify a literal, in other words, produce a new literal where the corresponding value is removed in case
// the literal hash is set.
func hashify(literal *core.Literal) *core.Literal {
// Two recursive cases:
// 1. A collection of literals or
// 2. A map of literals

if literal.GetCollection() != nil {
literals := literal.GetCollection().Literals
literalsHash := make([]*core.Literal, 0)
for _, lit := range literals {
literalsHash = append(literalsHash, hashify(lit))
}
return &core.Literal{
Value: &core.Literal_Collection{
Collection: &core.LiteralCollection{
Literals: literalsHash,
},
},
}
}
if literal.GetMap() != nil {
literalsMap := make(map[string]*core.Literal)
for key, lit := range literal.GetMap().Literals {
literalsMap[key] = hashify(lit)
}
return &core.Literal{
Value: &core.Literal_Map{
Map: &core.LiteralMap{
Literals: literalsMap,
},
},
}
}

// And a base case that consists of a scalar, where the hash might be set
if literal.GetHash() != "" {
return &core.Literal{
Hash: literal.GetHash(),
}
}
return literal
}

// Generate a tag by hashing the input values
func GenerateArtifactTagName(ctx context.Context, inputs *core.LiteralMap) (string, error) {
if inputs == nil || len(inputs.Literals) == 0 {
inputs = &emptyLiteralMap
}

// Hashify, i.e. generate a copy of the literal map where each literal value is removed
// in case the corresponding hash is set.
hashifiedLiteralMap := make(map[string]*core.Literal, len(inputs.Literals))
for name, literal := range inputs.Literals {
hashifiedLiteralMap[name] = hashify(literal)
}
hashifiedInputs := &core.LiteralMap{
Literals: hashifiedLiteralMap,
}

inputsHash, err := pbhash.ComputeHash(ctx, hashifiedInputs)
hashString, err := catalog.HashLiteralMap(ctx, inputs)
if err != nil {
return "", err
}

hashString := base64.RawURLEncoding.EncodeToString(inputsHash)
tag := fmt.Sprintf("%s-%s", cachedTaskTag, hashString)
return tag, nil
}
Expand Down
Loading

0 comments on commit 357bf09

Please sign in to comment.