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

[flyte deck] Streaming Decks #2779

Merged
merged 85 commits into from
Feb 5, 2025
Merged

[flyte deck] Streaming Decks #2779

merged 85 commits into from
Feb 5, 2025

Conversation

Future-Outlier
Copy link
Member

@Future-Outlier Future-Outlier commented Oct 1, 2024

Tracking issue

flyteorg/flyte#5574

Why are the changes needed?

we want to support streaming decks.

What changes were proposed in this pull request?

add a function publish for the Flyte Deck.

How was this patch tested?

from flytekit import ImageSpec, task, workflow
from flytekit.deck import Deck

flytekit_hash = "6b55930d0a77efc3594ebaac056f2c75024e61b5"
flytekit = f"git+https://github.com/flyteorg/flytekit.git@{flytekit_hash}"

# Define custom image for the task
custom_image = ImageSpec(packages=[flytekit],
                            apt_packages=["git"],
                            registry="localhost:30000",
                            env={"FLYTE_SDK_LOGGING_LEVEL": 10},
                         )

@task(enable_deck=False, container_image=custom_image)
def t_no_deck():
    # Deck.publish()
    print("No Deck")

@task(enable_deck=True, container_image=custom_image)
def t_deck():
    import time
    """
    1st deck only show timeline deck
    2nd will show
    """
    for i in range(3):
        Deck.publish()
        time.sleep(1)

@task(enable_deck=True, container_image=custom_image)
def t_fail_deck():
    import time

    for i in range(3):
        Deck.publish()
        time.sleep(3)
    time.sleep(10)
    raise ValueError("Failed Deck")

@workflow
def wf():
    t_no_deck()
    t_deck()
    t_fail_deck()

if __name__ == "__main__":
    from flytekit.clis.sdk_in_container import pyflyte
    from click.testing import CliRunner
    import os

    runner = CliRunner()
    path = os.path.realpath(__file__)

    result = runner.invoke(pyflyte.main,
                           ["run", path, "t_no_deck"])
    print("Local Execution: ", result.output)

    result = runner.invoke(pyflyte.main,
                           ["run", "--remote", path,"wf"])
    print("Remote Execution: ", result.output)

Setup process

single binary.

flyte: flyteorg/flyte#6053
flytekit: #2779
flyteconsole: flyteorg/flyteconsole#890

Screenshots

flytekit: this branch

NEW FLYTEKIT, NO DECK, RUNNING With Deck, SUCCEED, and FAILED

OSS-STREAMING-DECK-small.mov

OLD FLYTEKIT, NO DECK, RUNNING With Deck, SUCCEED, and FAILED

OSS-STREAMING-DECK-OLD-FLYTEKIT-small.mov

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

Implements comprehensive deck functionality improvements including Deck.publish() method and generates_deck flag handling, with enhanced error messaging. Added task name context to warning messages when enable_deck is False for clearer feedback. Refactors Protocol Buffer BoolValue wrapper from base task to models layer, improving error handling and attribute validation. Changes simplify task definition interface while maintaining proper protobuf serialization.

Unit tests added: True

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

Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.50%. Comparing base (4cee7cd) to head (c0fd23a).
Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2779       +/-   ##
===========================================
+ Coverage   77.90%   90.50%   +12.60%     
===========================================
  Files         217      108      -109     
  Lines       22178     4760    -17418     
  Branches     2768        0     -2768     
===========================================
- Hits        17277     4308    -12969     
+ Misses       4115      452     -3663     
+ Partials      786        0      -786     

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

Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
@Future-Outlier Future-Outlier changed the title [Flyte Deck] Streaming Decks [wip][Flyte Deck] Streaming Decks Oct 2, 2024
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
@kumare3
Copy link
Contributor

kumare3 commented Oct 9, 2024

I would love to see an example of tqdm

@kumare3
Copy link
Contributor

kumare3 commented Oct 9, 2024

replaces #1704

@Future-Outlier
Copy link
Member Author

I would love to see an example of tqdm

will try it, just let me ship the MSGPACK IDL first.

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will make it automatically refresh the page.. probably need that on the empty deck but not sure how to do the realtime behavior once it has content (you don't want to refresh while the user is browsing around or clicking through various tabs)

Suggested change
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="refresh" content="5" >

Copy link
Member Author

Choose a reason for hiding this comment

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

COOL, will try it, thank you

Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
@Future-Outlier Future-Outlier changed the title [wip][Flyte Deck] Streaming Decks [flytepropeller][flyteadmin] Streaming Decks Nov 27, 2024
@Future-Outlier Future-Outlier changed the title [flytepropeller][flyteadmin] Streaming Decks [flyte deck] Streaming Decks Nov 27, 2024
Copy link
Collaborator

@eapolinario eapolinario left a comment

Choose a reason for hiding this comment

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

This is pretty cool. It unlocks so many use cases!

I left just a couple of comments. We're very close.

Comment on lines -44 to -47
.. warning::

This feature is in beta.

Copy link
Collaborator

Choose a reason for hiding this comment

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

nice.

task_name = params.task_id.name

if not params.has_attr(ENABLE_DECK) or not params.enable_deck:
logger.warning("Deck is disabled for this task, please don't call Deck.publish()")
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's make this error message less charged. How about we say "Call to Deck.publish() will not generate flyte decks as enable_deck=False"?

if DeckField.TIMELINE.value in self.deck_fields and ctx.user_space_params is not None:
ctx.user_space_params.decks.append(ctx.user_space_params.timeline_deck)
if self.enable_deck and ctx.user_space_params is not None:
ctx.user_space_params.builder().add_attr(ENABLE_DECK, True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

because when disable deck, we shouldn't append deck.

@eapolinario
Copy link
Collaborator

there's something going on with the serialization tests (e.g.: https://github.com/flyteorg/flytekit/actions/runs/13126446467/job/36627463041?pr=2779). Can you take a look?

@Future-Outlier
Copy link
Member Author

there's something going on with the serialization tests (e.g.: https://github.com/flyteorg/flytekit/actions/runs/13126446467/job/36627463041?pr=2779). Can you take a look?

yes no problem

Signed-off-by: Future-Outlier <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 4, 2025

Code Review Agent Run #1c8466

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: ea8b6e0..a642c9d
    • flytekit/deck/deck.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

Signed-off-by: Future-Outlier <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 4, 2025

Code Review Agent Run #4926be

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: a642c9d..e9aef35
    • flytekit/tools/translator.py
    • tests/flytekit/unit/deck/test_deck.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

@eapolinario eapolinario mentioned this pull request Feb 4, 2025
8 tasks
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 4, 2025

Code Review Agent Run #bb9139

Actionable Suggestions - 4
  • tests/flytekit/unit/deck/test_deck.py - 2
    • Consider consolidating duplicate context assertions · Line 270-276
    • Consider consolidating repeated assertions · Line 282-301
  • flytekit/core/context_manager.py - 1
  • flytekit/deck/deck.py - 1
    • Consider attribute existence check for params · Line 90-90
Review Details
  • Files reviewed - 8 · Commit Range: e9aef35..b649f8f
    • flytekit/core/base_task.py
    • flytekit/core/constants.py
    • flytekit/core/context_manager.py
    • flytekit/core/type_engine.py
    • flytekit/deck/deck.py
    • flytekit/remote/remote.py
    • tests/flytekit/unit/core/test_unions.py
    • tests/flytekit/unit/deck/test_deck.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 5, 2025

Code Review Agent Run #c1727c

Actionable Suggestions - 1
  • flytekit/core/base_task.py - 1
    • Consider using BoolValue for generates_deck · Line 180-180
Review Details
  • Files reviewed - 3 · Commit Range: b649f8f..0565282
    • flytekit/core/base_task.py
    • flytekit/models/task.py
    • tests/flytekit/unit/test_translator.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

flytekit/deck/deck.py Outdated Show resolved Hide resolved
Signed-off-by: Future-Outlier <[email protected]>
Co-authored-by: pingsutw  <[email protected]>
@Future-Outlier Future-Outlier merged commit 2ef875c into master Feb 5, 2025
32 checks passed
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 5, 2025

Code Review Agent Run #a1d78e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 0565282..c0fd23a
    • flytekit/deck/deck.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

UmerAhmad pushed a commit to UmerAhmad/flytekit that referenced this pull request Feb 8, 2025
* [Flyte Decl] Streaming Decks

Signed-off-by: Future-Outlier <[email protected]>

* print

Signed-off-by: Future-Outlier <[email protected]>

* sleep more

Signed-off-by: Future-Outlier <[email protected]>

* add dummy deck

Signed-off-by: Future-Outlier <[email protected]>

* nit

Signed-off-by: Future-Outlier <[email protected]>

* dummy deck

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* nit

Signed-off-by: Future-Outlier <[email protected]>

* test

Signed-off-by: Future-Outlier <[email protected]>

* return html

Signed-off-by: Future-Outlier <[email protected]>

* Change Deck

Signed-off-by: Future-Outlier <[email protected]>

* fix

Signed-off-by: Future-Outlier <[email protected]>

* fix recursion error

Signed-off-by: Future-Outlier <[email protected]>

* remove redundant code

Signed-off-by: Future-Outlier <[email protected]>

* add dummy deck to deck init

Signed-off-by: Future-Outlier <[email protected]>

* Better Dummy Deck Logic

Signed-off-by: Future-Outlier <[email protected]>

* Deck Publish

Signed-off-by: Future-Outlier <[email protected]>

* litn

Signed-off-by: Future-Outlier <[email protected]>

* remove dummy deck

Signed-off-by: Future-Outlier <[email protected]>

* nit

Signed-off-by: Future-Outlier <[email protected]>

* use auto refresh tab, 5 seconds as interval

Signed-off-by: Future-Outlier <[email protected]>

* revert

Signed-off-by: Future-Outlier <[email protected]>

* test setDynamicTabs

Signed-off-by: Future-Outlier <[email protected]>

* change interval time

Signed-off-by: Future-Outlier <[email protected]>

* test

Signed-off-by: Future-Outlier <[email protected]>

* revert

Signed-off-by: Future-Outlier <[email protected]>

* test

Signed-off-by: Future-Outlier <[email protected]>

* nit

Signed-off-by: Future-Outlier <[email protected]>

* try dynamic containers

Signed-off-by: Future-Outlier <[email protected]>

* try dynamic containers v2

Signed-off-by: Future-Outlier <[email protected]>

* try dynamic containers v3

Signed-off-by: Future-Outlier <[email protected]>

* debug

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* nit

Signed-off-by: Future-Outlier <[email protected]>

* Refresh Botton

Signed-off-by: Future-Outlier <[email protected]>

* fix

Signed-off-by: Future-Outlier <[email protected]>

* lint

Signed-off-by: Future-Outlier <[email protected]>

* test new refresh

Signed-off-by: Future-Outlier <[email protected]>

* lint

Signed-off-by: Future-Outlier <[email protected]>

* Revert back html code, collaborating with Lyon

Signed-off-by: Future-Outlier <[email protected]>

* lint

Signed-off-by: Future-Outlier <[email protected]>

* nit

Signed-off-by: Future-Outlier <[email protected]>

* nit

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* better code

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* some notes for giving user params builder deck enabled

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* raise error when disabled deck and called Deck.publish()

Signed-off-by: Future-Outlier <[email protected]>

* lint

Signed-off-by: Future-Outlier <[email protected]>

* lint

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* static method by YEE

Signed-off-by: Future-Outlier <[email protected]>

* make Deck.publish more like a wrapper by moving enable deck checking to _output_deck

Signed-off-by: Future-Outlier <[email protected]>

* lint

Signed-off-by: Future-Outlier <[email protected]>

* print monodocs err

Signed-off-by: Future-Outlier <[email protected]>

* Fix monodocs

Signed-off-by: Future-Outlier <[email protected]>

* use builder

Signed-off-by: Future-Outlier <[email protected]>

* add translator test for deck serialization settings

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* fix

Signed-off-by: Future-Outlier <[email protected]>

* test

Signed-off-by: Future-Outlier <[email protected]>

* update

Signed-off-by: Future-Outlier <[email protected]>

* remove blank

Signed-off-by: Future-Outlier <[email protected]>

* update kevin's advice

Signed-off-by: Future-Outlier <[email protected]>
Co-authored-by: pingsutw  <[email protected]>

* master-branch-idl

Signed-off-by: Future-Outlier <[email protected]>

---------

Signed-off-by: Future-Outlier <[email protected]>
Co-authored-by: pingsutw <[email protected]>
Signed-off-by: Umer Ahmad <[email protected]>
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.

9 participants