cuddly-jelly-27016
04/30/2025, 9:37 AMDataFrame as input to a polars LazyFrame due to a Renderer for LazyFrame missing.
Since LazyFrames are supported out of the box, I was wondering why this is throwing an error as I did not explicitly ask for the input parameters being rendered in the Deck.
### Goal: What should the final outcome look like, ideally?
Add a renderer for a LazyFrame. Since these only contain the execution plan it should be fine to just display that (see below for suggested implementation).
I created a MRE:
class LazyFrameRenderer:
"""Display the execution plan of a LazyFrame."""
def to_html(self, df: pl.LazyFrame) -> str:
assert isinstance(df, pl.LazyFrame)
explain_string = df.explain()
return MarkdownIt().render(explain_string)
@task(container_image=ImageSpec(packages=["polars"]))
def get_data() -> pl.DataFrame:
return pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
@task(container_image=ImageSpec(packages=["polars"]), enable_deck=True)
def showcase_data(data: pl.DataFrame) -> Annotated[pl.LazyFrame, LazyFrameRenderer()]:
"""Showcase the data in a deck."""
return data.lazy()
@workflow()
def lazyframe_deck() -> pl.LazyFrame:
df = get_data()
lf = showcase_data(df)
return lf
### Describe alternatives you've considered
I also tried annotating the input parameter LazyFrame with a custom renderer, but this still did not work as the input parameters are checked from another list apparently.
### Propose: Link/Inline OR Additional context
class LazyFrameRenderer:
"""Display the execution plan of a LazyFrame."""
def to_html(self, df: pl.LazyFrame) -> str:
assert isinstance(df, pl.LazyFrame)
explain_string = df.explain()
return MarkdownIt().render(explain_string)
This renderer should probably be added to StructuredDatasetTransformerEngine.Renderers
### Are you sure this issue hasn't been raised already?
• Yes
### Have you read the Code of Conduct?
• Yes
flyteorg/flyte