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

Read offloaded literals #2685

Merged
merged 10 commits into from
Sep 18, 2024
Merged

Read offloaded literals #2685

merged 10 commits into from
Sep 18, 2024

Conversation

eapolinario
Copy link
Collaborator

@eapolinario eapolinario commented Aug 15, 2024

Tracking issue

Linking to the RFC: flyteorg/flyte#5103

Why are the changes needed?

As discussed in flyteorg/flyte#5103, flytekit needs to be able to read offloaded literals.

What changes were proposed in this pull request?

The type engine "unrolls" literals that contain offloaded literals prior to turning those into python values.

How was this patch tested?

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

Signed-off-by: Eduardo Apolinario <[email protected]>
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 56.25000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 58.40%. Comparing base (11c3a18) to head (cf51973).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
flytekit/models/literals.py 68.00% 8 Missing ⚠️
flytekit/core/type_engine.py 14.28% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2685      +/-   ##
==========================================
- Coverage   66.44%   58.40%   -8.05%     
==========================================
  Files           9      302     +293     
  Lines         453    24748   +24295     
  Branches        0     2867    +2867     
==========================================
+ Hits          301    14453   +14152     
- Misses        152     9777    +9625     
- Partials        0      518     +518     

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

@eapolinario eapolinario changed the title [WIP] - Read offloaded literals Read offloaded literals Sep 18, 2024
Signed-off-by: Eduardo Apolinario <[email protected]>
@@ -852,6 +852,52 @@ def from_flyte_idl(cls, pb2_object):
)


class LiteralOffloadedMetadata(_common.FlyteIdlEntity):
Copy link
Contributor

Choose a reason for hiding this comment

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

Not your change, but a generator class for this could be useful

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do you mean like a utility function to help in tests?

@eapolinario eapolinario enabled auto-merge (squash) September 18, 2024 15:31
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Minor nit on test, otherwise LGTM

)

# Write offloaded_lv as bytes to a temp file
with open(f"{tmp_path}/offloaded_proto.pb", "wb") as f:
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised using / works with windows. I usually go with:

Suggested change
with open(f"{tmp_path}/offloaded_proto.pb", "wb") as f:
with (tmp_path / "offloaded_proto.pb").open("wb") as f:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's a good call. I'm going to fix this in a separate PR.

As for what happens on windows, my guess is that the / becomes part of the file name.

@eapolinario eapolinario merged commit 2dcbb90 into master Sep 18, 2024
103 of 105 checks passed
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.

3 participants