Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
Signed-off-by: pmahindrakar-oss <[email protected]>
  • Loading branch information
pmahindrakar-oss committed Oct 1, 2024
1 parent b6b10e3 commit 0542dab
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions flytepropeller/pkg/controller/nodes/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ func ReadLargeLiteral(ctx context.Context, datastore *storage.DataStore,
if tobeRead.GetOffloadedMetadata() == nil {
return fmt.Errorf("unsupported type for reading offloaded literal")

Check warning on line 88 in flytepropeller/pkg/controller/nodes/common/utils.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/common/utils.go#L88

Added line #L88 was not covered by tests
}
// read the offloaded literal
dataReference := tobeRead.GetOffloadedMetadata().GetUri()
if dataReference == "" {
return fmt.Errorf("uri is empty for offloaded literal")

Check warning on line 92 in flytepropeller/pkg/controller/nodes/common/utils.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/common/utils.go#L92

Added line #L92 was not covered by tests
}
// read the offloaded literal
size := tobeRead.GetOffloadedMetadata().GetSizeBytes()
if err := datastore.ReadProtobuf(ctx, storage.DataReference(dataReference), tobeRead); err != nil {
logger.Errorf(ctx, "Failed to read the offloaded literal at location [%s] with error [%s]", dataReference, err)
Expand Down Expand Up @@ -127,13 +130,17 @@ func OffloadLargeLiteral(ctx context.Context, datastore *storage.DataStore, data
logger.Errorf(ctx, "Failed to offload literal at location [%s] with error [%s]", dataReference, err)
return err
}
// compute the hash of the literal
literalDigest, err := pbhash.ComputeHash(ctx, toBeOffloaded)
if err != nil {
logger.Errorf(ctx, "Failed to compute hash for offloaded literal with error [%s]", err)
return err
}

if toBeOffloaded.GetHash() == "" {
// compute the hash of the literal
literalDigest, err := pbhash.ComputeHash(ctx, toBeOffloaded)
if err != nil {
logger.Errorf(ctx, "Failed to compute hash for offloaded literal with error [%s]", err)
return err

Check warning on line 139 in flytepropeller/pkg/controller/nodes/common/utils.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/common/utils.go#L138-L139

Added lines #L138 - L139 were not covered by tests
}
// Set the hash or else respect what the user set in the literal
toBeOffloaded.Hash = base64.RawURLEncoding.EncodeToString(literalDigest)
}
// update the literal with the offloaded URI, size and inferred type
toBeOffloaded.Value = &idlcore.Literal_OffloadedMetadata{
OffloadedMetadata: &idlcore.LiteralOffloadedMetadata{
Expand All @@ -142,10 +149,6 @@ func OffloadLargeLiteral(ctx context.Context, datastore *storage.DataStore, data
InferredType: inferredType,
},
}
if toBeOffloaded.GetHash() == "" {
// Set the hash or else respect what the user set in the literal
toBeOffloaded.Hash = base64.RawURLEncoding.EncodeToString(literalDigest)
}
logger.Infof(ctx, "Offloaded literal at location [%s] with size [%d] MB and inferred type [%s]", dataReference, literalSizeMB, inferredType)
return nil
}
Expand Down

0 comments on commit 0542dab

Please sign in to comment.