Skip to content

[Core feature] Reuse same literals in the dynamic task - #3307

Merged
pingsutw merged 10 commits into
flyteorg:masterfrom
BarryWu0812:#6032
Sep 19, 2025
Merged

[Core feature] Reuse same literals in the dynamic task#3307
pingsutw merged 10 commits into
flyteorg:masterfrom
BarryWu0812:#6032

Conversation

@BarryWu0812

@BarryWu0812 BarryWu0812 commented Aug 2, 2025

Copy link
Copy Markdown
Contributor

Tracking issue

Closes flyteorg/flyte#6032

Why are the changes needed?

We should only serialize the variable and upload it once to reuse the same input.

To make the same Python value reuse the literal.

What changes were proposed in this pull request?

Add a local cache to store the literal that has been serialized.

How was this patch tested?

Unit test

Check all the applicable boxes

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

Summary by Bito

This pull request enhances the Flyte framework by implementing a local caching mechanism using an LRU cache for serialized literals, replacing the previous cache. This improvement boosts efficiency by reducing redundant serialization and uploads of identical Python values. A new unit test has been added to verify caching behavior when pandas is unavailable, and existing unit tests have been updated to ensure the new caching behavior is validated.

Signed-off-by: Barry Wu <a0987818905@gmail.com>
…ache

Signed-off-by: Barry Wu <a0987818905@gmail.com>
@codecov

codecov Bot commented Aug 5, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 23.52941% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.97%. Comparing base (eb5a67f) to head (9597122).
⚠️ Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
flytekit/core/type_engine.py 23.52% 13 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (eb5a67f) and HEAD (9597122). Click for more details.

HEAD has 75 uploads less than BASE
Flag BASE (eb5a67f) HEAD (9597122)
100 25
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3307       +/-   ##
===========================================
- Coverage   85.26%   44.97%   -40.29%     
===========================================
  Files         386      319       -67     
  Lines       30276    26812     -3464     
  Branches     2969     2953       -16     
===========================================
- Hits        25814    12060    -13754     
- Misses       3615    14655    +11040     
+ Partials      847       97      -750     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Barry Wu <a0987818905@gmail.com>
Comment thread flytekit/core/type_engine.py Outdated
Comment thread flytekit/core/type_engine.py Outdated
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Signed-off-by: Barry Wu <a0987818905@gmail.com>
Comment thread flytekit/core/type_engine.py Outdated
Comment thread tests/flytekit/unit/core/test_list.py
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Comment thread flytekit/core/type_engine.py
Comment thread flytekit/core/type_engine.py Outdated
Comment thread flytekit/core/type_engine.py Outdated
Signed-off-by: Barry Wu <a0987818905@gmail.com>

@machichima machichima left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall LGTM! Thank you!

Just some nit

Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Comment thread tests/flytekit/unit/core/test_list.py
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Signed-off-by: Barry Wu <a0987818905@gmail.com>
@BarryWu0812
BarryWu0812 requested a review from machichima August 15, 2025 06:42
Signed-off-by: Barry Wu <a0987818905@gmail.com>
Comment thread tests/flytekit/unit/core/test_type_engine.py Outdated
Signed-off-by: Barry Wu <a0987818905@gmail.com>
@BarryWu0812
BarryWu0812 requested a review from machichima August 22, 2025 07:15
Co-authored-by: Nary Yeh <60069744+machichima@users.noreply.github.com>
Comment thread flytekit/core/type_engine.py Outdated
Comment thread flytekit/core/type_engine.py Outdated
Signed-off-by: Barry Wu <a0987818905@gmail.com>
@BarryWu0812
BarryWu0812 requested a review from pingsutw August 27, 2025 16:03
@pingsutw
pingsutw merged commit 9effe91 into flyteorg:master Sep 19, 2025
112 of 115 checks passed
Atharva1723 pushed a commit to Atharva1723/flytekit that referenced this pull request Oct 5, 2025
Signed-off-by: Barry Wu <a0987818905@gmail.com>
Co-authored-by: Kevin Su <pingsutw@gmail.com>
Co-authored-by: Nary Yeh <60069744+machichima@users.noreply.github.com>
Signed-off-by: Atharva <atharvakulkarni172003@gmail.com>
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.

[Core feature] Reuse same literals in the dynamic task

4 participants