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

Commit

Permalink
Update flytepropeller
Browse files Browse the repository at this point in the history
Signed-off-by: Bernhard Stadlbauer <[email protected]>
  • Loading branch information
bstadlbauer committed Jun 19, 2023
1 parent 89dfd5b commit 1a6c9e9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 641 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ require (
)

replace github.com/aws/amazon-sagemaker-operator-for-k8s => github.com/aws/amazon-sagemaker-operator-for-k8s v1.0.1-0.20210303003444-0fb33b1fd49d

// FIXME: Don't merge, replace with proper version once merged
replace github.com/flyteorg/flyteplugins => ../flyteplugins
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYF
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/flyteorg/flyteidl v1.5.10 h1:SHeiaWRt8EAVuFsat+BJswtc07HTZ4DqhfTEYSm621k=
github.com/flyteorg/flyteidl v1.5.10/go.mod h1:EtE/muM2lHHgBabjYcxqe9TWeJSL0kXwbI0RgVwI4Og=
github.com/flyteorg/flyteplugins v1.0.67 h1:d2FXpwxQwX/k4YdmhuusykOemHb/cUTPEob4WBmdpjE=
github.com/flyteorg/flyteplugins v1.0.67/go.mod h1:HHt4nKDKVwrZPKDsj99dNtDSIJL378xNotYMA3a/TFA=
github.com/flyteorg/flytestdlib v1.0.15 h1:kv9jDQmytbE84caY+pkZN8trJU2ouSAmESzpTEhfTt0=
github.com/flyteorg/flytestdlib v1.0.15/go.mod h1:ghw/cjY0sEWIIbyCtcJnL/Gt7ZS7gf9SUi0CCPhbz3s=
github.com/flyteorg/stow v0.3.6 h1:jt50ciM14qhKBaIrB+ppXXY+SXB59FNREFgTJqCyqIk=
Expand Down
64 changes: 2 additions & 62 deletions pkg/controller/nodes/task/catalog/datacatalog/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,72 +116,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
return "", nil
}

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

0 comments on commit 1a6c9e9

Please sign in to comment.