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

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open

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

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

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 81.52%. Comparing base (f99d50e) to head (d48efa9).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
flytekit/deck/deck.py 50.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2779       +/-   ##
===========================================
+ Coverage   51.08%   81.52%   +30.43%     
===========================================
  Files         201      201               
  Lines       21231    21246       +15     
  Branches     2731     2731               
===========================================
+ Hits        10846    17320     +6474     
+ Misses       9787     3163     -6624     
- Partials      598      763      +165     

☔ 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
@kumare3
Copy link
Contributor

kumare3 commented Dec 3, 2024

Nice, I just would make a small refresh icon in grey next to the name, but all good

@Future-Outlier
Copy link
Member Author

Nice, I just would make a small refresh icon in grey next to the name, but all good

okok, I will change this

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
Copy link
Member Author

this is the new video!!!
https://drive.google.com/file/d/1TpTqMjWJURN7q35ZOB5rIkPQPkIztjCq/view?usp=sharing
cc @kumare3 @pingsutw @eapolinario @EngHabu @wild-endeavor

@kumare3
Copy link
Contributor

kumare3 commented Dec 5, 2024

@Future-Outlier this is excellent. Let's go

Comment on lines 91 to 93
task_name = FlyteContextManager.current_context().user_space_params.task_id.name
new_user_params = FlyteContextManager.current_context().user_space_params
_output_deck(task_name=task_name, new_user_params=new_user_params)
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
task_name = FlyteContextManager.current_context().user_space_params.task_id.name
new_user_params = FlyteContextManager.current_context().user_space_params
_output_deck(task_name=task_name, new_user_params=new_user_params)
params = FlyteContextManager.current_context().user_space_params
task_name = params.task_id.name
_output_deck(task_name=task_name, new_user_params=params)

@pingsutw
Copy link
Member

FYI @fg91 since you also want to use it. would love to get your feedback

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

fg91 commented Dec 17, 2024

FYI @fg91 since you also want to use it. would love to get your feedback

I'm a big fan of such a feature - being able to publish realtime updates from a task to flyte console was the topic of various discussions in the past (e.g. this or this):

    # A very similar API was discussed back then:
    deck = flytekit.Deck("Summary", ...)
    deck.append(MarkdownRenderer.to_html(f"... {run.link} ..."))
    deck.flush()

I have one question about the implementation. Does flytepropeller need to detect whenever the deck html in the bucket changed for the change to be reflected in the UI or does propeller only indicate to the task where to upload the deck to but a request from flyteconsole directly "goes to the bucket" without flytepropeller having to do further work?

@Future-Outlier
Copy link
Member Author

FYI @fg91 since you also want to use it. would love to get your feedback

I'm a big fan of such a feature - being able to publish realtime updates from a task to flyte console was the topic of various discussions in the past (e.g. this or this):

    # A very similar API was discussed back then:
    deck = flytekit.Deck("Summary", ...)
    deck.append(MarkdownRenderer.to_html(f"... {run.link} ..."))
    deck.flush()

I have one question about the implementation. Does flytepropeller need to detect whenever the deck html in the bucket changed for the change to be reflected in the UI or does propeller only indicate to the task where to upload the deck to but a request from flyteconsole directly "goes to the bucket" without flytepropeller having to do further work?

I will reply this later, just finished an amazing solution about the backend with backward compatibility.

@Future-Outlier
Copy link
Member Author

Future-Outlier commented Dec 17, 2024

FYI @fg91 since you also want to use it. would love to get your feedback

I'm a big fan of such a feature - being able to publish realtime updates from a task to flyte console was the topic of various discussions in the past (e.g. this or this):

    # A very similar API was discussed back then:
    deck = flytekit.Deck("Summary", ...)
    deck.append(MarkdownRenderer.to_html(f"... {run.link} ..."))
    deck.flush()

I have one question about the implementation. Does flytepropeller need to detect whenever the deck html in the bucket changed for the change to be reflected in the UI or does propeller only indicate to the task where to upload the deck to but a request from flyteconsole directly "goes to the bucket" without flytepropeller having to do further work?

old flyte backend:
flyte-propeller called a head request to see if the deck exists or not.
new flyte backend:
flytepropeller check if we put FLYTE_ENABLE_DECK=true in the task template.

Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[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.

5 participants