diff --git a/plugins/flytekit-deck-standard/flytekitplugins/deck/renderer.py b/plugins/flytekit-deck-standard/flytekitplugins/deck/renderer.py index 1aca9595ce..708e941d88 100644 --- a/plugins/flytekit-deck-standard/flytekitplugins/deck/renderer.py +++ b/plugins/flytekit-deck-standard/flytekitplugins/deck/renderer.py @@ -8,13 +8,11 @@ import markdown import pandas as pd import PIL.Image - import plotly.express as px import pygments import ydata_profiling else: pd = lazy_module("pandas") markdown = lazy_module("markdown") - px = lazy_module("plotly.express") PIL = lazy_module("PIL") ydata_profiling = lazy_module("ydata_profiling") pygments = lazy_module("pygments") @@ -96,6 +94,8 @@ def __init__(self, column_name): self._column_name = column_name def to_html(self, df: "pd.DataFrame") -> str: + import plotly.express as px + fig = px.box(df, y=self._column_name) return fig.to_html() @@ -135,7 +135,9 @@ class TableRenderer: Convert a pandas DataFrame into an HTML table. """ - def to_html(self, df: pd.DataFrame, header_labels: Optional[List] = None, table_width: Optional[int] = None) -> str: + def to_html( + self, df: "pd.DataFrame", header_labels: Optional[List] = None, table_width: Optional[int] = None + ) -> str: # Check if custom labels are provided and have the correct length if header_labels is not None and len(header_labels) == len(df.columns): df = df.copy() @@ -184,7 +186,9 @@ class GanttChartRenderer: - "Name": string (the name of the task or event) """ - def to_html(self, df: pd.DataFrame, chart_width: Optional[int] = None) -> str: + def to_html(self, df: "pd.DataFrame", chart_width: Optional[int] = None) -> str: + import plotly.express as px + fig = px.timeline(df, x_start="Start", x_end="Finish", y="Name", color="Name", width=chart_width) fig.update_xaxes( diff --git a/plugins/flytekit-deck-standard/setup.py b/plugins/flytekit-deck-standard/setup.py index c707084161..6ba3dfb02d 100644 --- a/plugins/flytekit-deck-standard/setup.py +++ b/plugins/flytekit-deck-standard/setup.py @@ -4,9 +4,7 @@ microlib_name = f"flytekitplugins-{PLUGIN_NAME}-standard" -plugin_requires = [ - "flytekit", -] +plugin_requires = ["flytekit"] __version__ = "0.0.0+develop"