flytekit icon indicating copy to clipboard operation
flytekit copied to clipboard

Real time deck support

Open Yicheng-Lu-llll opened this issue 1 year ago • 11 comments

TL;DR

This PR adds real-time deck support.

After this PR, User can use flytekit.Deck.persist() to generate the html based on current collected metrics/information. So that user can see the real time deck even the task is running or has already failed. See the below example:

import flytekit
from flytekit import Resources, task, workflow
from flytekit.core.utils import timeit

@task(
    disable_deck=False,
    limits=Resources(mem="4Gi", cpu="1"),
)
def t1():
    import time

    for i in range(2):
        # timeit measure the time used in the block and shown in time line deck. See https://github.com/flyteorg/flytekit/pull/1581. 
        # Or you can add information to your own deck. See https://docs.flyte.org/projects/cookbook/en/latest/auto/core/flyte_basics/deck.html.
        with timeit(f"iteration {i}"):
            time.sleep(50)
        flytekit.Deck.persist()


@workflow
def wf():
    t1()


if __name__ == "__main__":
    wf()

截屏2023-06-23 22 39 08 截屏2023-06-23 22 39 23

real time deck support includes:

  • flytekit: https://github.com/flyteorg/flytekit/pull/1704
  • flyteadmin: https://github.com/flyteorg/flyteadmin/pull/579
  • flytepropeller: https://github.com/flyteorg/flytepropeller/pull/579
  • flyteconsole: https://github.com/flyteorg/flyteconsole/pull/781

Type

  • [ ] Bug Fix
  • [x] Feature
  • [ ] Plugin

Are all requirements met?

  • [ ] Code completed
  • [ ] Smoke tested
  • [ ] Unit tests added
  • [ ] Code documentation added
  • [ ] Any pending items have an associated Issue

Yicheng-Lu-llll avatar Jun 22 '23 00:06 Yicheng-Lu-llll

Just realizing we could use this feature to solve this problem: provide the ability to display links to e.g. wandb runs which are generated at runtime before the task ends 🎉

fg91 avatar Jun 30 '23 17:06 fg91

This also solves the problem with eager mode, i.e. we can re-render the Flyte deck of subtasks being kicked-off by the eager workflow in real-time.

cosmicBboy avatar Jul 24 '23 21:07 cosmicBboy

How does this effort here relate to the discussion in https://github.com/flyteorg/flyte/discussions/3838 btw? (cc @hamersaw)

fg91 avatar Jul 25 '23 09:07 fg91

@fg91 yeah, this is one of the issues that is effectively blocked, I would rather merge this with a re-usable flytekit -> flytepropeller communication mechanism.

hamersaw avatar Jul 25 '23 12:07 hamersaw