Skip to content

Implement rich_repr for expressions - #19173

Merged
rapids-bot[bot] merged 5 commits into
NVIDIA:branch-25.08from
TomAugspurger:tom/rich-print
Jun 18, 2025
Merged

Implement rich_repr for expressions#19173
rapids-bot[bot] merged 5 commits into
NVIDIA:branch-25.08from
TomAugspurger:tom/rich-print

Conversation

@TomAugspurger

Copy link
Copy Markdown
Contributor

Description

This adds a __rich_repr__ implmementation for cudf-polars' internal data structures Expr and PartitionInfo that should be a bit easier to read while debugging. There's no dependency (required or optional) on rich. There's no change to the regular repr used by Python to print objects. To see the change, use rich.pretty.print.

Here's a screenshot of the output:

import polars as pl
import rich.pretty
from cudf_polars.dsl.translate import Translator

ldf = pl.LazyFrame({"a": ["a", "b", "c", "d", "a", None, "b", "c"]})
q = ldf.group_by((pl.col("a").str.starts_with("a"))).agg(
    pl.col("a").count().alias("count")
)

ir = Translator(q._ldf.visit(), engine=pl.GPUEngine()).translate_ir()

print("default")
print("-" * 80)
print(ir, end="\n\n")

print("rich")
print("-" * 80)
rich.pretty.pprint(ir)

image

@copy-pr-bot

copy-pr-bot Bot commented Jun 16, 2025

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added Python Affects Python cuDF API. cudf-polars Issues specific to cudf-polars labels Jun 16, 2025
@GPUtester GPUtester moved this to In Progress in cuDF Python Jun 16, 2025
@TomAugspurger TomAugspurger added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jun 16, 2025
@TomAugspurger
TomAugspurger marked this pull request as ready for review June 16, 2025 14:03
@TomAugspurger
TomAugspurger requested a review from a team as a code owner June 16, 2025 14:03
@TomAugspurger
TomAugspurger requested review from bdice and vyasr June 16, 2025 14:03
@TomAugspurger
TomAugspurger requested review from a team as code owners June 17, 2025 14:40
@github-actions github-actions Bot added libcudf Affects libcudf (C++/CUDA) code. CMake CMake build issue cudf.pandas Issues specific to cudf.pandas pylibcudf Issues specific to the pylibcudf package labels Jun 17, 2025
@TomAugspurger
TomAugspurger removed request for a team June 17, 2025 14:41
@github-actions github-actions Bot removed libcudf Affects libcudf (C++/CUDA) code. CMake CMake build issue cudf.pandas Issues specific to cudf.pandas pylibcudf Issues specific to the pylibcudf package labels Jun 17, 2025
@TomAugspurger

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit b9fb517 into NVIDIA:branch-25.08 Jun 18, 2025
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cudf-polars Issues specific to cudf-polars improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants