Skip to content

Commit

Permalink
Update FlyteDeck Example (#1734)
Browse files Browse the repository at this point in the history
* use V2 instead

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

* update flyte deck example

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

* nit

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

---------

Signed-off-by: Future-Outlier <[email protected]>
  • Loading branch information
Future-Outlier authored Sep 26, 2024
1 parent b7b0f7a commit a1dde19
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions examples/development_lifecycle/development_lifecycle/decks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
# https://docs.flyte.org/en/latest/user_guide/customizing_dependencies/imagespec.html#image-spec-example

custom_image = ImageSpec(
packages=["plotly", "scikit-learn", "flytekitplugins-deck-standard"], registry="ghcr.io/flyteorg"
packages=[
"flytekitplugins-deck-standard",
"markdown",
"pandas",
"pillow",
"plotly",
"pyarrow",
"scikit-learn",
"ydata_profiling",
],
registry="ghcr.io/flyteorg",
)

if custom_image.is_container():
Expand Down Expand Up @@ -47,7 +57,7 @@ def pca_plot():
from flytekitplugins.deck.renderer import FrameProfilingRenderer


@task(enable_deck=True)
@task(enable_deck=True, container_image=custom_image)
def frame_renderer() -> None:
df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
flytekit.Deck("Frame Renderer", FrameProfilingRenderer().to_html(df=df))
Expand All @@ -61,7 +71,7 @@ def frame_renderer() -> None:
from flytekit.deck import TopFrameRenderer


@task(enable_deck=True)
@task(enable_deck=True, container_image=custom_image)
def top_frame_renderer() -> Annotated[pd.DataFrame, TopFrameRenderer(1)]:
return pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})

Expand All @@ -70,7 +80,7 @@ def top_frame_renderer() -> Annotated[pd.DataFrame, TopFrameRenderer(1)]:
# producing HTML as a Unicode string.


@task(enable_deck=True)
@task(enable_deck=True, container_image=custom_image)
def markdown_renderer() -> None:
flytekit.current_context().default_deck.append(
MarkdownRenderer().to_html("You can install flytekit using this command: ```import flytekit```")
Expand All @@ -87,7 +97,7 @@ def markdown_renderer() -> None:
from flytekitplugins.deck.renderer import BoxRenderer


@task(enable_deck=True)
@task(enable_deck=True, container_image=custom_image)
def box_renderer() -> None:
iris_df = px.data.iris()
flytekit.Deck("Box Plot", BoxRenderer("sepal_length").to_html(iris_df))
Expand All @@ -101,7 +111,7 @@ def box_renderer() -> None:
from flytekitplugins.deck.renderer import ImageRenderer


@task(enable_deck=True)
@task(enable_deck=True, container_image=custom_image)
def image_renderer(image: FlyteFile) -> None:
flytekit.Deck("Image Renderer", ImageRenderer().to_html(image_src=image))

Expand All @@ -117,7 +127,7 @@ def image_renderer_wf(
from flytekitplugins.deck.renderer import TableRenderer


@task(enable_deck=True)
@task(enable_deck=True, container_image=custom_image)
def table_renderer() -> None:
flytekit.Deck(
"Table Renderer",
Expand Down

0 comments on commit a1dde19

Please sign in to comment.