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

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

Merged
merged 7 commits into from
Feb 21, 2025

Conversation

eapolinario
Copy link
Contributor

@eapolinario eapolinario commented Jan 27, 2025

Tracking issue

N/A

Why are the changes needed?

flyteconsole has a tough time rendering primitive attribute fields. For example, an execution of this workflow:

from dataclasses import dataclass
from flytekit import task, workflow

@dataclass
class Inner:
    a: int
    b: float
    c: str

@dataclass
class DC:
    a: int
    b: float
    c: str
    inner: Inner

@task
def t(dc: DC):
    print(dc)

@task
def t_int(x: int):
    print(x)

@task
def t_float(x: float):
    print(x)

@task
def t_str(x: str):
    print(x)

@task
def t_inner(x: Inner):
    print(x)

@workflow
def wf(dc: DC):
    t(dc)
    t_int(dc.a)
    t_float(dc.b)
    t_str(dc.c)
    t_inner(dc.inner)
    t_int(dc.inner.a)
    t_float(dc.inner.b)
    t_str(dc.inner.c)

All the fields are misrendered, for example, the argument to t_str is rendered like:
image

After this change this is rendered like:
image

What changes were proposed in this pull request?

In order to help flyteconsole render primitive attributes we turn those fields into scalar literals.

How was this patch tested?

unit tests and local sandbox.

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

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 83.67347% with 8 lines in your changes missing coverage. Please review.

Project coverage is 36.88%. Comparing base (e9e227b) to head (20194de).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...opeller/pkg/controller/nodes/attr_path_resolver.go 83.67% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6194      +/-   ##
==========================================
+ Coverage   36.86%   36.88%   +0.01%     
==========================================
  Files        1318     1318              
  Lines      134773   134820      +47     
==========================================
+ Hits        49683    49726      +43     
- Misses      80758    80760       +2     
- Partials     4332     4334       +2     
Flag Coverage Δ
unittests-datacatalog 51.58% <ø> (ø)
unittests-flyteadmin 51.87% <ø> (ø)
unittests-flytecopilot 30.99% <ø> (ø)
unittests-flytectl 62.29% <ø> (ø)
unittests-flyteidl 7.22% <ø> (ø)
unittests-flyteplugins 54.00% <ø> (ø)
unittests-flytepropeller 42.86% <83.67%> (+0.07%) ⬆️
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.

Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
@eapolinario eapolinario changed the title wip - Override literal in the case of attribute access of primitive values Override literal in the case of attribute access of primitive values Feb 20, 2025
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
@eapolinario eapolinario added the changed For changes in existing functionality label Feb 20, 2025
@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 21, 2025

Code Review Agent Run Status

  • Limitations and other issues: ❌ Failure - Bito Code Review Agent didn't review this pull request automatically because it exceeded the size limit. No action is needed if you didn't intend for the agent to review it. Otherwise, you can initiate the review by typing /review in a comment below.

wild-endeavor
wild-endeavor previously approved these changes Feb 21, 2025
Copy link
Contributor

@wild-endeavor wild-endeavor left a comment

Choose a reason for hiding this comment

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

only question is around the uints... is it worth checking the value for overload?

@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 21, 2025

Code Review Agent Run Status

  • Limitations and other issues: ❌ Failure - Bito Code Review Agent didn't review this pull request automatically because it exceeded the size limit. No action is needed if you didn't intend for the agent to review it. Otherwise, you can initiate the review by typing /review in a comment below.

@eapolinario eapolinario merged commit 6c2624b into master Feb 21, 2025
51 checks passed
@eapolinario eapolinario deleted the override-attr-access-primitive-types branch February 21, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changed For changes in existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants