Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip - Override literal in the case of attribute access of primitive values #6194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eapolinario
Copy link
Contributor

@eapolinario eapolinario commented Jan 27, 2025

Tracking issue

N/A

Why are the changes needed?

What changes were proposed in this pull request?

How was this patch tested?

Labels

Please add one or more of the following labels to categorize your PR:

  • added: For new features.
  • changed: For changes in existing functionality.
  • deprecated: For soon-to-be-removed features.
  • removed: For features being removed.
  • fixed: For any bug fixed.
  • security: In case of vulnerabilities

This is important to improve the readability of release notes.

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Summary by Bito

This PR enhances the attribute path resolver by adding support for handling primitive type values in binary IDL. The changes introduce automatic conversion of primitive types (string, int, float64, and boolean) into their corresponding literal scalar representations, improving the system's flexibility in attribute handling.

Unit tests added: False

Estimated effort to review (1-5, lower is better): 1

@flyte-bot
Copy link
Collaborator

flyte-bot commented Jan 27, 2025

Code Review Agent Run #31d7d8

Actionable Suggestions - 1
  • flytepropeller/pkg/controller/nodes/attr_path_resolver.go - 1
    • Consider extracting primitive type conversion logic · Line 187-244
Review Details
  • Files reviewed - 1 · Commit Range: e26023f..e26023f
    • flytepropeller/pkg/controller/nodes/attr_path_resolver.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

@flyte-bot
Copy link
Collaborator

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Enhanced Primitive Type Handling in Attribute Path Resolution

attr_path_resolver.go - Added support for converting primitive types (string, int, float64, bool) to literal scalars during attribute path resolution

Comment on lines +187 to +244
// Check if the current value is a primitive type, and if it is convert that to a literal scalar
if _, ok := currVal.(string); ok {
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: &core.Primitive{
Value: &core.Primitive_StringValue{
StringValue: currVal.(string),
},
},
},
},
},
}, nil
} else if _, ok := currVal.(int); ok {
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: &core.Primitive{
Value: &core.Primitive_Integer{
Integer: int64(currVal.(int)),
},
},
},
},
},
}, nil
} else if _, ok := currVal.(float64); ok {
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: &core.Primitive{
Value: &core.Primitive_FloatValue{
FloatValue: currVal.(float64),
},
},
},
},
},
}, nil
} else if _, ok := currVal.(bool); ok {
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: &core.Primitive{
Value: &core.Primitive_Boolean{
Boolean: currVal.(bool),
},
},
},
},
},
}, nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting primitive type conversion logic

Consider extracting primitive type conversion logic into a separate helper function to improve code maintainability and reduce duplication. The current implementation has similar conversion patterns repeated for different primitive types.

Code suggestion
Check the AI-generated fix before applying
Suggested change
// Check if the current value is a primitive type, and if it is convert that to a literal scalar
if _, ok := currVal.(string); ok {
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: &core.Primitive{
Value: &core.Primitive_StringValue{
StringValue: currVal.(string),
},
},
},
},
},
}, nil
} else if _, ok := currVal.(int); ok {
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: &core.Primitive{
Value: &core.Primitive_Integer{
Integer: int64(currVal.(int)),
},
},
},
},
},
}, nil
} else if _, ok := currVal.(float64); ok {
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: &core.Primitive{
Value: &core.Primitive_FloatValue{
FloatValue: currVal.(float64),
},
},
},
},
},
}, nil
} else if _, ok := currVal.(bool); ok {
return &core.Literal{
Value: &core.Literal_Scalar{
Scalar: &core.Scalar{
Value: &core.Scalar_Primitive{
Primitive: &core.Primitive{
Value: &core.Primitive_Boolean{
Boolean: currVal.(bool),
},
},
},
},
},
}, nil
}
// Convert primitive types to literal scalar
if lit, err := convertPrimitiveToLiteral(currVal); err == nil {
return lit, nil
}

Code Review Run #31d7d8


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.39%. Comparing base (45ce4c0) to head (e26023f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6194      +/-   ##
==========================================
- Coverage   37.08%   35.39%   -1.69%     
==========================================
  Files        1318     1002     -316     
  Lines      132707   102296   -30411     
==========================================
- Hits        49208    36210   -12998     
+ Misses      79244    63091   -16153     
+ Partials     4255     2995    -1260     
Flag Coverage Δ
unittests-datacatalog 51.58% <ø> (ø)
unittests-flyteadmin 54.34% <ø> (ø)
unittests-flytecopilot 30.99% <ø> (ø)
unittests-flytectl 62.29% <ø> (ø)
unittests-flyteidl 7.23% <ø> (ø)
unittests-flyteplugins 53.87% <ø> (ø)
unittests-flytepropeller ?
unittests-flytestdlib 55.33% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants